uikit

UIKit

UIKit imperative UI framework patterns

Details

Language / Topic
swiftSwift
Category
framework
Compatible Frameworks
uikit

Rules

balanced
- Use Auto Layout constraints (`NSLayoutConstraint`) or `UIStackView` for all layouts — never hardcode frame positions.
- Follow the delegate pattern for `UITableView`/`UICollectionView` — implement `numberOfRows`, `cellForRow`, and `didSelectRow` in dedicated data source classes.
- Use `UIViewController` lifecycle methods correctly: setup views in `viewDidLoad`, layout in `viewDidLayoutSubviews`, cleanup in `deinit`.
- Use Diffable Data Sources (`UICollectionViewDiffableDataSource`) for collection/table views — they handle animations and updates automatically.
- Use `UICollectionViewCompositionalLayout` for modern collection views — avoid `UITableView` for new features.
- Use `UIViewController` containment (child VCs) for reusable, composable screen sections.
- Use `UINavigationController` push/pop for hierarchical navigation and `UITabBarController` for top-level tabs.
- Use `Diffable Data Sources` (`UICollectionViewDiffableDataSource`) for type-safe, animated data updates.
- Implement `dequeueReusableCell(withReuseIdentifier:)` for memory-efficient cell reuse in lists.