Posts tagged iOS
ForEach and ID
Why SwiftUI's ForEach needs an id and how to handle duplicate elements
Fitting a UIImageView to its image size
How to remove leftover padding by computing a UIImageView's height from the image ratio
Passing Data from a Child View to a Parent View (PreferenceKey, GeometryReader)
Get a child view's size with GeometryReader and pass it up to the parent view with PreferenceKey.
UICollectionViewHeader with Dynamic Height
Use systemLayoutSizeFitting to calculate the height from the subview constraints and set the collection view header height dynamically.
Fixing the withAnimation Bug
Fixed the problem where withAnimation in onAppear also moves an unrelated view, by using the animation modifier.
ForEach's ID
What ForEach's id does, and how to wrap values in Identifiable when they overlap.
keyPath as a function
Since Swift 5.2 you can pass a keyPath like a function, which makes map and filter shorter.
Fitting a UIImageView to the Image size
Remove the extra margin in a scaleAspectFit image view by setting a height constraint from the image's aspect ratio.
Calling a completionHandler after multiple async calls
To call several async functions and handle the result once after all of them finish, use DispatchGroup's enter, leave and notify.
Cell event error
When a view put in a cell doesn't respond to taps: the problem caused by contentView, and how to fix it.
addGestureRecognizer vs addTarget
The difference between addGestureRecognizer, used on UIView, and addTarget, used on UIControl.
When property observers get called
A didSet on an array property is called in all three cases: replacing the array, replacing an element, and changing a property of an element.
UITextView's intrinsicContentSize
UITextView only has an intrinsicContentSize when isScrollEnabled is false.
Fixing the Firebase currentUser error in iOS Swift
Why Firebase Auth's currentUser can be empty, and how to fix it by receiving the sign-in state with a listener.
Generics in Documents
Notes on the Generics chapter of the Swift docs, with example code.






