Uikit
44 bites tagged Uikit — interview questions with model answers, and 60-second explainers.
Push vs Modal Presentation in UIKit
Push adds to a nav stack with back, modal presents a self-contained interrupting flow. understanding of UIKit navigation models. treating them as interchangeable or ignoring the stack relationship.
IBOutlet vs IBAction in Interface Builder
Outlet references a view, action handles an event, both connect via Ctrl-drag. grasp of Storyboard-to-code wiring. confusing the two directions or forgetting the connection is runtime, not compile-time.
Play a remote video with AVFoundation
Wrap the URL in AVPlayerItem, feed it to AVPlayer, render with AVPlayerLayer added to the view's layer (or AVPlayerViewController for controls). Knowing the AVPlayer rendering stack.
Build an interruptible custom VC transition
A delegate vends an animator (UIViewControllerAnimatedTransitioning) for the visuals and an interactive controller (UIViewControllerInteractiveTransitioning) driven by a pan to scrub progress and… The custom transition protocol stack.
Allow simultaneous pan and pinch gestures
Attach pan and pinch recognizers, set yourself as delegate, return true from shouldRecognizeSimultaneouslyWith, apply translation to center and scale to transform. Simultaneous gesture recognition via the delegate.
Build a custom circular progress bar in UIKit
Draw an arc with UIBezierPath, assign it to a CAShapeLayer path, set lineWidth and no fill, animate strokeEnd 0 to 1. Vector drawing with CAShapeLayer plus strokeEnd animation.
Difference between frame, bounds, and center
Frame and center are in the superview's space; bounds is the view's own space, usually origin zero. A non-identity transform makes frame undefined to read. Coordinate systems and transform effects.
Add shadow and rounded corners to a UIView
CornerRadius needs masksToBounds true, but that clips the shadow; set shadowPath to keep both and stay performant. CALayer shadow and corner properties plus the masksToBounds conflict.
Explain UIKit MVC and the Massive View Controller problem
Model holds data, View displays it, Controller mediates between them; the view controller accretes networking, parsing, and logic into a Massive View Controller. understanding UIKit's core pattern and its pitfall.
Describe the iOS app lifecycle and SceneDelegate methods
Not running, inactive, active, background, suspended; SceneDelegate handles sceneDidBecomeActive, sceneWillResignActive, sceneDidEnterBackground, sceneWillEnterForeground. knowledge of app and scene states.
How does Auto Layout resolve constraints?
Auto Layout solves a system of prioritized linear equations; intrinsicContentSize is a view's natural size; hugging resists growing, compression resistance resists shrinking. understanding constraint-based layout.
Design state-driven navigation for a conditional wizard in UIKit and SwiftUI
This tests separating navigation state from UI. Model the flow as a state machine enum, derive the stack from state, and unit test transitions in plain Swift. A red flag is imperative pushes inside views or view controllers.
How would you architect the app root for onboarding vs authenticated flows?
Tests window root swapping and state-driven architecture. Use a coordinator to own the window, swap rootViewController between nav and tab controllers on auth changes, and crossfade. Red flag: onboarding modal over tabs or keeping both hierarchies alive.
Handle a deep link URL in SceneDelegate and navigate to order detail.
Handles willConnectTo and openURLContexts; parses path with URLComponents; validates ID; pushes detail onto nav stack. iOS scene-based deep links. Forgetting warm launches or routing without checking view hierarchy.
Pass data back from a modally presented view controller delegate versus closure
This tests decoupled UIKit communication and memory safety. A strong answer outlines a weak delegate protocol and a closure with weak self, contrasting coupling and retain cycles. Red flag: singletons or direct parent references.
Outline the key steps and APIs for State Preservation and Restoration
Tests UIKit's automatic state restoration pipeline. Strong answers cover: opting in via AppDelegate, setting restorationIdentifiers, implementing encode/decodeRestorableStateWithCoder, and the system snapshot cycle.
How does the Coordinator pattern decouple navigation, and what are its components?
This tests iOS separation of concerns. Explain that Coordinators extract navigation logic from view controllers for reuse, and describe AppCoordinator tree with child coordinators. A red flag is treating it as a router or ignoring parent-child retention.
How do AppDelegate and SceneDelegate responsibilities differ?
AppDelegate owns process events (launch, push); SceneDelegate owns per-window lifecycle and UI. iOS 13 scene architecture mastery. Putting all UI logic in AppDelegate or claiming SceneDelegate is optional.
Integrate SwiftUI into UIKit and wrap UIKit for SwiftUI
Tests bridging architecture between UIKit and SwiftUI using UIHostingController and UIViewRepresentable. A strong answer names hosting controllers for SwiftUI in UIKit, representable protocols for UIKit in SwiftUI, and lifecycle hooks.
Compare UIKit Auto Layout and SwiftUI layout systems
Tests imperative versus declarative layout paradigms. Contrast UIKit's constraint solver with SwiftUI's two-pass sizing and composition via stacks and modifiers instead of anchors. Red flag: claiming SwiftUI uses Auto Layout under the hood.
How do UITableView and UICollectionView reuse cells?
This tests your understanding of UIKit's flyweight pattern and scroll performance. A strong answer covers the reuse pool, dequeueReusableCell mapping identifiers to new index paths, and registration.
When should you use frame-based layout versus Auto Layout?
Frames suit static or high-frequency UI like particle systems; Auto Layout handles rotation, Dynamic Type, localization, and split screen. When manual frames beat constraints. Claiming Auto Layout always wins.
Explain symbolic breakpoints and debug Auto Layout with one
Tests debugging closed-source frameworks without source lines. A strong answer says a symbolic breakpoint stops on UIViewAlertForUnsatisfiableConstraints, then checks the backtrace or log to find the bad view.
Custom Rendering with draw(_:)
draw(_:) is the callback where UIKit asks your view for pixels. Override it to render custom shapes or text with Core Graphics when stock views fall short. The footgun is calling it directly or doing non-drawing work inside; use setNeedsDisplay() instead.
Get Uikit bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.