Write, review, or improve UIKit code following best practices for view controller lifecycle, Auto Layout, collection views, navigation, animation, memory management, and modern iOS 18–26 APIs. Use when building new UIKit features, refactoring existing views or view controllers, reviewing code quality, adopting modern UIKit patterns (diffable data sources, compositional layout, cell configuration), or bridging UIKit with SwiftUI. Does not cover SwiftUI-only code.
96
100%
Does it follow best practices?
Impact
96%
1.23xAverage score across 9 eval scenarios
Passed
No known issues
The mobile team at a photo-sharing app needs a profile screen built entirely in code (no Storyboard or XIB). The screen shows a horizontally scrollable strip of the user's photos at the top, followed by a bio section that can be expanded or collapsed by the user. When navigating to a profile from a photo detail view, the app should restore context by scrolling the photo strip to the last photo the user was viewing.
The profile screen is used from multiple entry points: the main feed taps into it mid-scroll, and deep links from push notifications can pre-select a specific photo. The current placeholder implementation loses the user's place every time the screen appears, which is jarring. It also triggers layout warnings in the console that make it hard to debug constraint issues in production crash logs.
The engineering team has agreed on a few requirements: the bio section must animate smoothly when toggling between expanded and collapsed states, the animation must not cause layout thrashing, and the code must be clean enough for a junior engineer to follow which constraint is which from the crash logs alone.
Implement the ProfileViewController as a single Swift file named ProfileViewController.swift. The view controller must:
init(selectedPhotoIndex: Int))The file should be a self-contained UIKit view controller implementation. Do not produce a full Xcode project — just the Swift source file.