Display clearColor UIViewController over UIViewController

iOS8+ In iOS8+ you can now use the new modalPresentationStyle UIModalPresentationOverCurrentContext to present a view controller with a transparent background: MyModalViewController *modalViewController = [[MyModalViewController alloc] init]; modalViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self presentViewController:modalViewController animated:YES completion:nil];

Animate change of view controllers without using navigation controller stack, subviews or modal controllers?

EDIT: New answer that works in any orientation. The original answer only works when the interface is in portrait orientation. This is b/c view transition animations that replace a view w/ a different view must occur with views at least a level below the first view added to the window (e.g. window.rootViewController.view.anotherView). I’ve implemented a … Read more

Fatal error: use of unimplemented initializer ‘init(coder:)’ for class

Issue This is caused by the absence of the initializer init?(coder aDecoder: NSCoder) on the target UIViewController. That method is required because instantiating a UIViewController from a UIStoryboard calls it. To see how we initialize a UIViewController from a UIStoryboard, please take a look here Why is this not a problem with Objective-C? Because Objective-C … Read more

dismissModalViewController AND pass data back

You need to use delegate protocols… Here’s how to do it: Declare a protocol in your secondViewController’s header file. It should look like this: #import <UIKit/UIKit.h> @protocol SecondDelegate <NSObject> -(void)secondViewControllerDismissed:(NSString *)stringForFirst @end @interface SecondViewController : UIViewController { id myDelegate; } @property (nonatomic, assign) id<SecondDelegate> myDelegate; Don’t forget to synthesize the myDelegate in your implementation (SecondViewController.m) … Read more

Programmatically set the initial view controller using Storyboards

How to without a dummy initial view controller Ensure all initial view controllers have a Storyboard ID. In the storyboard, uncheck the “Is initial View Controller” attribute from the first view controller. If you run your app at this point you’ll read: Failed to instantiate the default view controller for UIMainStoryboardFile ‘MainStoryboard’ – perhaps the … Read more

Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7

Starting in iOS7, the view controllers use full-screen layout by default. At the same time, you have more control over how it lays out its views, and that’s done with those properties: edgesForExtendedLayout Basically, with this property you set which sides of your view can be extended to cover the whole screen. Imagine that you … Read more