Uikit
44 bites tagged Uikit — interview questions with model answers, and 60-second explainers.
Unwind Segues: Jump Back in the Stack
An unwind segue jumps from a deep screen to an earlier view controller without manual popping. Use it after multi-step flows to return to a root screen. If multiple screens share the same action, UIKit picks the nearest one and silently routes users wrong.
CATransaction: Grouping Core Animation Changes
Think of CATransaction as an atomic 'commit' for UI animations, grouping layer property changes to appear at once. Use it to synchronize animations or set a custom duration for a batch of changes.
Creating Custom Gestures by Subclassing UIGestureRecognizer
Subclassing UIGestureRecognizer lets you build a custom state machine for touch events. Use it for unique interactions like a rotary dial. The footgun is state management: you must explicitly update the gesture's state or it will never be recognized.
UIBezierPath: Drawing Custom Shapes in Code
UIBezierPath is a digital pen for drawing custom shapes. You define a path with lines and curves, then fill or stroke it. It's essential for custom charts, icons, or non-rectangular views.
NSFetchedResultsController: The Bridge for Core Data & UI
NSFetchedResultsController is a bridge that automatically syncs a Core Data database with a UITableView. It efficiently manages data fetching, memory, and UI updates for dynamic lists, like a social feed.
Custom UIViewController Transitions: Beyond the Defaults
A custom transition lets you choreograph the handoff between two screens, defining the exact animation. Use it for unique experiences like a card expanding to fill the screen.
Storyboard Segues: Visual UI Flow in iOS
A Storyboard Segue is a visual arrow connecting two screens in your iOS app, defining a navigation path without writing code. Use them to transition from a list to a detail view. The biggest mistake is forgetting to use `prepare(for:sender:)` to pass data.
UITabBarController: Your App's Main Switchboard
A UITabBarController manages a row of buttons at the bottom of the screen to switch between an app's main sections. Use it for distinct, non-sequential modes like 'Recents,' 'Contacts,' and 'Voicemail'. The footgun is using it for a step-by-step process.
UINavigationController: Stack-Based Screen Management
UINavigationController manages screens like a deck of cards: you push new ones on top and pop them off to go back. It's standard for hierarchical navigation. The footgun is manually changing the stack; always use the provided push/pop methods.
iOS State Preservation: Resume Where You Left Off
Think of it as an automatic bookmark for your app's UI. When iOS terminates your app, state preservation can save the user's place, restoring the view hierarchy on next launch.
UISceneDelegate: Managing Your App's UI Instances
Think of SceneDelegate as the lifecycle manager for a single window of your app's UI. It's essential for multi-window iPad apps, handling when a scene connects, disconnects, or changes state.
The AppDelegate: Your App's Central Command
Think of the AppDelegate as your app's command center, receiving critical notifications from the OS. It handles core events like launch, termination, or receiving a push notification. The footgun is bloating it with logic that belongs elsewhere.
UIViewRepresentable: Bridging UIKit and SwiftUI
UIViewRepresentable is an adapter that lets you use battle-tested UIKit views inside your modern SwiftUI code. Use it for components like WKWebView that lack a native SwiftUI equivalent.
The Responder Chain: Who Handles That Tap?
The Responder Chain is iOS's chain of command for events. When a user taps the screen, the event travels up a view hierarchy, asking each object, "Can you handle this?" until one accepts. Accidentally breaking this chain can silently kill event handling.
UIHostingController: Bridge SwiftUI into UIKit Apps
UIHostingController is an adapter that lets you use modern SwiftUI views inside a UIKit app by wrapping them in a UIViewController. This is key for migrating apps to SwiftUI or embedding new components.
UICollectionView: Grids, Stacks, and Custom Layouts
UICollectionView is a powerful tool for displaying items in customizable layouts, going far beyond a simple vertical list. Use it for photo galleries or App Store-style interfaces.
UITableView: The Backbone of iOS Lists
UITableView is the workhorse for displaying scrolling lists in iOS. It's used everywhere from Settings to Contacts. The footgun is forgetting to reuse cells, which causes massive memory usage and choppy scrolling, so always dequeue a reusable cell.
SwiftUI Stacks: Arrange Views Vertically, Horizontally, and in Layers
SwiftUI stacks are your core layout tools for arranging views. Use VStack for vertical columns, HStack for horizontal rows, and ZStack for layering. They're essential for any UI, from simple rows to complex overlays.
UIStackView: Layouts Without Manual Constraints
A UIStackView is an invisible container that arranges views in a single column or row, saving you from writing manual layout constraints. It's ideal for toolbars or forms. The main footgun is forgetting it's non-rendering—you can't set its background color.
UIView: The Building Block of iOS UIs
A UIView is the fundamental building block for iOS UIs. Think of it as a rectangular canvas for drawing content, handling touches, or containing other views. You use it everywhere, from simple buttons to complex layouts.
Get Uikit bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.