topLayoutGuide in child view controller

While this answer might be correct, I still found myself having to travel the containment tree up to find the right parent view controller and get what you describe as the “real topLayoutGuide“. This way I can manually implement automaticallyAdjustsScrollViewInsets. This is how I’m doing it: In my table view controller (a subclass of UIViewController … Read more

iOS viewDidLoad for UIView

If you load it from a XIB file, the awakeFromNib method will be called once loading finishes: override public func awakeFromNib() { super.awakeFromNib(); // … loading logic here … } Update; In the case of no XIB, you will probably have to infer it using one of the methods from the Observing View-Related Changes area … Read more

How to call a View Controller programmatically?

To create a view controller: UIViewController * vc = [[UIViewController alloc] init]; To call a view controller (must be called from within another viewcontroller): [self presentViewController:vc animated:YES completion:nil]; For one, use nil rather than null. Loading a view controller from the storyboard: NSString * storyboardName = @”MainStoryboard”; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; UIViewController … Read more

iOS7 UIModalTransitionStyleFlipHorizontal bounces after transition

This appears to be a UIKit bug. The following workaround seems to resolve the issue for me. – (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController.navigationBar.layer removeAllAnimations]; } (Place this in the view controller you are transitioning to).

How to add an UIViewController’s view as subview

As of iOS 5, Apple now allows you to make custom containers for the purpose of adding a UIViewController to another UIViewController particularly via methods such as addChildViewController so it is indeed possible to nest UIViewControllers EDIT: Including in-place summary so as to avoid link breakage I quote: iOS provides many standard containers to help … Read more

Move UIView up when the keyboard appears in iOS

– (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } – (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; } #pragma mark – keyboard movements – (void)keyboardWillShow:(NSNotification *)notification { CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; [UIView animateWithDuration:0.3 animations:^{ CGRect f … Read more

Display UIViewController as Popup in iPhone

NOTE : This solution is broken in iOS 8. I will post new solution ASAP. I am going to answer here using storyboard but it is also possible without storyboard. Init: Create two UIViewController in storyboard. lets say FirstViewController which is normal and SecondViewController which will be the popup. Modal Segue: Put UIButton in FirstViewController … Read more