Scroll & Collection ViewControllers
ViewControllerSpecialized view controller base classes for form screens, collection views, and search screens — all built on TTBaseUIViewController.
| Class | Description |
|---|---|
TTBaseScrollViewController | VC with embedded TTBaseScrollPanelView — ideal for long forms |
TTBaseStackScrollViewController | VC with scrollable vertical stack for adding views dynamically |
TTBaseUICollectionViewController | UICollectionViewController with keyboard dismiss support |
TTBaseUISearchViewController | VC with search bar at top + results below |
📜 TTBaseScrollViewController
class ProfileFormViewController: TTBaseScrollViewController {
// Optional: customize insets
override var paddingScroll: (CGFloat, CGFloat, CGFloat, CGFloat) {
return (0, TTSize.H_NAV, 0, TTSize.H_TABBAR + TTSize.P_CONS_DEF)
}
// Optional: allow horizontal constraint
override var isSetWidth: Bool { return true }
// Optional: keyboard dismiss mode
override var keyboardDismissMode: UIScrollView.KeyboardDismissMode {
return .onDrag
}
override func viewDidLoad() {
super.viewDidLoad()
// Add form content to baseScrollView's stack
let nameField = LabelTextFieldView(label: "Full Name")
let emailField = LabelTextFieldView(label: "Email")
let submitBtn = TTBaseUIButton(textString: "Save", type: .WARRING, isSetSize: false)
// If stack is available:
[nameField, emailField, submitBtn].forEach {
baseScrollView.stackView?.addArrangedSubview($0)
}
}
}
📱 TTBaseUICollectionViewController
class PhotoGridViewController: TTBaseUICollectionViewController<TTBaseUIView> {
override func viewDidLoad() {
super.viewDidLoad()
collectionView.register(PhotoCell.self, forCellWithReuseIdentifier: "Cell")
}
override func collectionView(_ collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return photos.count
}
override func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! PhotoCell
cell.configure(with: photos[indexPath.item])
return cell
}
}
Pro Tip: Use
TTBaseScrollViewController for any screen with 3+ form fields — it handles the keyboard-avoidance automatically via keyboardDismissMode = .onDrag. You get proper scroll + keyboard behavior without manual NotificationCenter keyboard observer code.