Custom smaller Detents in UISheetPresentationController?

For iOS 16+ Swift – custom(identifier:resolver:) ObjC – customDetentWithIdentifier:resolver: For iOS 15 : Use +[UISheetPresentationControllerDetent _detentWithIdentifier:constant:]. It’s a private method. Sample Summary: UIKitCore`+[UISheetPresentationControllerDetent _detentWithIdentifier:constant:] Address: UIKitCore[0x00000001838d50fc] (UIKitCore.__TEXT.__text + 17876312)

Is the weakSelf/strongSelf dance really necessary when referencing self inside a non-retained completion called from a UIViewController?

As I believe you correctly diagnosed, using self will not necessarily cause strong reference cycle in this scenario. But this will retain the view controller while the network operation completes, and in this case (as in most cases), there’s no need to. Thus, it may not be necessary to do use weakSelf, but probably prudent … Read more

Add toolbar to UITableViewController

No problem at all, UITableViewController is a subclass of UIViewController. And it so happens that in iPhone OS 3.0 any UIViewController (and subclasses) can work in conjunction with a UINavigationController to provide a context aware toolbar. In order for this to work you must: Make sure that you use a UINavigationController to contain all your … Read more

PageViewController current page index in Swift

You can use didFinishAnimating, and set tags to viewcontrollers. try this func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { if (!completed) { return } self.pageControl.currentPageIndex = pageViewController.viewControllers!.first!.view.tag //Page Index }

Get the current displaying UIViewController on the screen in AppDelegate.m

I always love solutions that involve categories as they are bolt on and can be easily reused. So I created a category on UIWindow. You can now call visibleViewController on UIWindow and this will get you the visible view controller by searching down the controller hierarchy. This works if you are using navigation and/or tab … Read more

Use of background/foreground methods in AppDelegate

Each object receive a UIApplicationDidEnterBackgroundNotification notification when the app goes in background. So to run some code when the app goes in background, you just have to listen to that notification where you want : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appHasGoneInBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; Don’t forget to release the listener when you don’t need to listen to it … Read more