Refresh UIPageViewController – reorder pages and add new pages

I found a workaround to force UIPageViewController to forget about cached view controllers of neighboring pages that are currently not displayed: pageViewController.dataSource = nil; pageViewController.dataSource = self; I do this everytime I change the set of pages. Of course this doesn’t affect the currently displayed page. With this workaround I avoid the caching bug and … Read more

Presenting a view controller modally from an action sheet’s delegate in iOS8 – iOS11

Update: As of iOS 9 SDK, UIActionSheet is deprecated, so do not expect a fix regarding this issue. It is best to start using UIAlertController when possible. The problem seems to come from Apple’s switch to using UIAlertController internally to implement the functionality of alert views and action sheets. The issue is seen mostly on … Read more

How is the relation between UIView’s clipsToBounds and CALayer’s masksToBounds?

They are different names because UIView and CALayer are different and have different terminology associated with them, but they are functionally equivalent. If you disassemble clipsToBounds you will see it just calls masksToBounds (disassembly from the simulator framework, so x86): -(BOOL)[UIView(Rendering) clipsToBounds] +0 3091938a 55 pushl %ebp +1 3091938b 89e5 movl %esp,%ebp +3 3091938d e800000000 … Read more

How can I add CGPoint objects to an NSArray the easy way?

With UIKit Apple added support for CGPoint to NSValue, so you can do: NSArray *points = [NSArray arrayWithObjects: [NSValue valueWithCGPoint:CGPointMake(5.5, 6.6)], [NSValue valueWithCGPoint:CGPointMake(7.7, 8.8)], nil]; List as many [NSValue] instances as you have CGPoint, and end the list in nil. All objects in this structure are auto-released. On the flip side, when you’re pulling the … Read more