UIKit interview questions
50 questions from real iOS interviews. Topics: View lifecycle, Auto Layout, rendering, UICollectionView, touch events.
- UIKitShort answer
frame vs bounds
While debugging a custom UIKit view you notice bounds.origin isn't (0, 0). What's the difference between frame and bounds?
#frame #bounds #coordinate #scrollview
- UIKitMultiple choice
View controller lifecycle
When a screen appears for the first time, which order do the UIViewController lifecycle methods run in?
#viewcontroller #lifecycle #viewdidload #viewdidappear
- UIKitShort answer
Auto Layout basics
How is an Auto Layout constraint represented internally, as a formula?
#autolayout #constraint #nslayoutanchor #visual-format
- UIKitMultiple choice
Safe Area
Which of the following statements about the Safe Area are correct? Pick all that apply.
#safe-area #layout-guide #notch #autolayout
- UIKitMultiple choice
Leading vs Left
When would it be appropriate to use leftAnchor instead of leadingAnchor in an Auto Layout constraint?
#autolayout #leading #rtl #localization
- UIKitShort answerUber
Storyboards vs code UI
Your team is debating whether to use storyboards or build UI purely in code. What are the pros and cons of each?
#storyboard #xib #programmatic-ui #git-conflict
- UIKitMultiple choiceZomato
UIResponder inheritance chain
Which is the correct inheritance chain from NSObject down to UIButton?
#uiresponder #uicontrol #inheritance #uibutton
- UIKitShort answer
viewDidLoad and network requests
A teammate kicks off a network request directly in viewDidLoad and updates the UI when the response arrives. What problems can this cause?
#viewdidload #lifecycle #network #task
- UIKitMultiple choice
Content Hugging and Compression Resistance
You've placed titleLabel and dateLabel side by side on one row with Auto Layout. When the title gets long, the title should shrink (truncate) and the date shou…
#autolayout #hugging #compression-resistance #priority
- UIKitShort answer
Intrinsic Content Size
You put a custom view you built (say, a tag chip view) into a UIStackView and it's sized to zero and invisible. How would you explain the cause and the fix in …
#autolayout #intrinsic-content-size #custom-view #invalidate
- UIKitShort answerTikTok
Layout update methods
What do setNeedsLayout and layoutIfNeeded each do in UIKit, and when should you call them?
#setneedslayout #layoutifneeded #layoutsubviews #setneedsdisplay
- UIKitMultiple choice
Constraint animation
This Auto Layout code is meant to slide a panel up, but the panel jumps into place with no animation. Why? …
#autolayout #animation #layoutifneeded #constraint
- UIKitShort answer
Cell reuse and async images
You've inherited a UITableView feed where, on fast scrolling, images briefly show up in the wrong cell and then get replaced. What's the cause?
#tableview #collectionview #cell-reuse #async-image
- UIKitMultiple choice
dequeueReusableCell API
Which statements about UITableView's dequeueReusableCell(withIdentifier:for:) and dequeueReusableCell(withIdentifier:) are correct? Pick all that apply.
#tableview #dequeue #reuse-identifier #register
- UIKitShort answer
Dynamic cell height
You need a UITableView cell whose height varies with the length of a comment. What do you set up so the cell height fits its content automatically?
#tableview #self-sizing #automatic-dimension #estimated-height
- UIKitShort answerTikTok
Responder chain and hit testing
When you tap the screen in a UIKit app, how does the system decide which view receives the touch (hit testing)?
#responder-chain #hit-test #touch #first-responder
- UIKitShort answer
View hierarchy traversal
How would you write a function that starts at a root view and finds a view matching some condition (say, tag == 99 or a specific type)? …
#view-hierarchy #bfs #dfs #subviews
- UIKitMultiple choice
Dark Mode support
Which statements about supporting Dark Mode in a UIKit app are correct? Pick all that apply.
#dark-mode #trait-collection #dynamic-color #cgcolor
- UIKitShort answerGoogle
Pinning four corners with constraints
Live coding. Given an [UIImage], how would you build a custom UIView that pins one image to each of its four corners using only constraints in code? …
#autolayout #nslayoutconstraint #anchor #programmatic-ui
- UIKitShort answerSwiggy
Sticky header, carousel, pull to refresh
A take-home review. The home screen needs (1) a filter header that stays pinned to the top while scrolling and (2) two rows of horizontally scrolling carousels…
#uicollectionview #compositional-layout #sticky-header #carousel
- UIKitMultiple choice라인
Calls before viewDidLoad
For a UIViewController instantiated from a storyboard, which methods are called before viewDidLoad()? Pick all that apply.
#lifecycle #loadview #awakefromnib #init-coder
- UIKitShort answerByteDance
Separating dataSource and delegate
Why did Apple design UITableView with two protocols, dataSource and delegate, instead of just letting you hand it a data array?
#uitableview #datasource #delegate #protocol
- UIKitMultiple choiceTencent
Table view call order
In a UITableView that doesn't use estimatedRowHeight, what's the correct order these four methods are called in right after reloadData()? - numberOfSections(in…
#uitableview #datasource #heightforrow #estimatedrowheight
- UIKitShort answerLyft
Image cell reuse and cancellation
In a UIKit collection view with image cells, fast scrolling makes the previous request's response flash on a reused cell before it changes. What would you canc…
#uikit #collection-view #image-loading #reuse
- UIKitShort answerOracleinterview report
Finding the common UIView parent
You're writing a function that finds the nearest common parent of two UIViews. Which data structure would you keep one view's superview chain in?
#uiview #view-hierarchy #ancestor #set
- UIKitShort answerBBCinterview report
List UI with a completed state
A UIKit table screen shows election results. Once every district's result has arrived, the refresh button should hide and the winner's row should be highlighte…
#uitableview #diffable-data-source #state #snapshot
- UIKitShort answer더스윙interview report
Auto Layout priorities
On a narrow screen, a title label and a price label have to share one row, and both demand their full text width. In Auto Layout, what decides which label gets…
#autolayout #constraint-priority #hugging #compression-resistance
- UIKitShort answerInstacart
Undoable game state
A tic-tac-toe game built with UIKit needs unlimited undo. What would you store to support undoing?
#state-management #undo #snapshot #uikit
- UIKitShort answerJD.com
Chat input bar and keyboard layout
In a UIKit chat screen, the input bar has to sit right on top of the keyboard and follow it as it rises. How would you connect keyboard height changes to Auto …
#keyboard #autolayout #chat #safe-area
- UIKitShort answer카카오모빌리티interview report
Self-sizing cells and Dynamic Type
A UIKit car listing cell has to grow in height and not truncate under the accessibility large text settings. How do you set up the constraints so the cell heig…
#dynamic-type #self-sizing #uikit #accessibility
- UIKitMultiple choice
Overriding hitTest
You've put a round button in the middle of a custom UIKit tab bar that sticks 20pt up above it. Tapping the part that sticks out does nothing. Which override b…
#hit-test #touch #custom-view #bounds
- UIKitShort answer
UIView and CALayer
How do UIView and CALayer relate to each other, and why are their roles split?
#calayer #uiview #core-animation #rendering
- UIKitShort answerAirbnbinterview report
Nested scrolling cell design
You need to put a horizontally scrolling UICollectionView inside a UITableViewCell in code (a carousel row like the App Store's Today tab). Who should own the …
#tableview #collectionview #nested #cell-reuse
- UIKitShort answerSnapinterview report
Diagnosing scroll performance
You get a report that scrolling stutters on a feed screen that mixes images and text. Where do you start, and how do you check?
#performance #scroll #instruments #hitch
- UIKitShort answer
Compositional Layout and Diffable Data Source
You're moving a screen built with UICollectionViewFlowLayout and an index-based dataSource to UICollectionViewCompositionalLayout and UICollectionViewDiffableD…
#collectionview #compositional-layout #diffable-datasource #snapshot
- UIKitMultiple choice
Diffable Data Source behavior
Which statements about using UICollectionViewDiffableDataSource are correct? Pick all that apply.
#diffable-datasource #snapshot #hashable #collectionview
- UIKitShort answer
Finding the common superview
Given several UIViews, how would you design a function that returns their nearest common superview?
#view-hierarchy #superview #lca #algorithm
- UIKitShort answerMeta
Reimplementing UIScrollView
Suppose UIScrollView didn't exist and you had to build a UIView subclass where content follows your finger. Which property would you change to move the content?
#uiscrollview #bounds #pan-gesture #contentoffset
- UIKitShort answerReddit
Cell impression tracking
Each post in a feed has to send an impression event exactly once when it has been at least 50% visible for at least 1 second. How would you design this impress…
#uitableview #impression #analytics #willdisplay
- UIKitShort answerZomato
Corner cycling animation
A 25-minute UIKit exercise. A small logo view has to move through the four corners in order, top-left, top-right, bottom-right, bottom-left, forever, like the …
#uiview-animate #animation #completion #uiviewpropertyanimator
- UIKitShort answer크림
UICollectionView internals
Why use UICollectionView instead of UITableView? Explain it in terms of the internal structure: the layout object, attributes, and reuse.
#uicollectionview #uicollectionviewlayout #layout-attributes #custom-layout
- UIKitShort answerBaidu
Per-cell countdown with reuse
Each cell in a UITableView flash sale list shows a countdown like "Time left 00:12:34" that ticks down every second. Instead of one Timer per cell, how would y…
#uitableview #timer #cell-reuse #prepareforreuse
- UIKitShort answerMicrosoft
Linked collection and table scrolling
A contacts screen in code review. A horizontally scrolling UICollectionView of letter indexes sits on top, a sectioned UITableView of contacts below; scrolling…
#uicollectionview #uitableview #scrollviewdidscroll #synchronized-scroll
- UIKitMultiple choiceAlibaba Group
Reused cells and CALayer
When you add layer effects like gradients, shadows, and animations to reusable UIKit cells, which statements describe a real problem and its correct fix? Pick …
#cell-reuse #calayer #shadowpath #gradient
- UIKitShort answerPinterestinterview report
Flood fill on a large grid
You're implementing flood fill on a large pixel grid drawn with a collection view (say, 500×500). If you don't use recursive DFS, how would you write the trave…
#collection-view #flood-fill #bfs #batch-updates
- UIKitShort answer
Offscreen rendering and the render pipeline
In a UIKit list, you applied layer.cornerRadius plus masksToBounds plus shadow to cells with profile images and the scroll frame rate dropped. From the render …
#rendering #offscreen #core-animation #gpu
- UIKitShort answer
Core Animation model and presentation layers
A view animates across the screen over 3 seconds with a UIView animation. Tapping it mid-flight does nothing, and printing view.frame mid-animation already sho…
#core-animation #presentation-layer #model-layer #animation
- UIKitShort answer
Auto Layout performance
On a screen made of complex cells with hundreds of constraints, the layout pass shows up as the bottleneck. Based on how the Auto Layout engine works, what dri…
#autolayout #performance #cassowary #constraint
- UIKitMultiple choice
UIKit render loop pass order
In one cycle of the main run loop, what's the correct order of the passes UIKit runs to update the screen? (Assume there are views marked with setNeedsUpdateCo…
#runloop #layout-pass #update-constraints #display
- UIKitShort answer네이버웹툰
Making the case for UICollectionView
The project has hundreds of UITableView screens. You want to propose moving them to UICollectionView. How would you persuade the teammates who object?
#uitableview #uicollectionview #migration #list-configuration