Linking child view controllers to a parent view controller within storyboard

As something of a combo of Caleb and Matt’s answers, I did: -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@”cpdc_check_embed”]) { self.checkVC = segue.destinationViewController; } } …where checkVC is a property on the container controller: @property (weak,nonatomic) PXPCheckViewController * checkVC; You just have to set your embed segue’s Storyboard ID to whatever you want (in this … Read more

What is the process of a UIViewController birth (which method follows which)?

There is a lot going on behind the scenes with Cocoa view and viewController management. 1. The viewController object At its most basic, a viewController is a generic controller object. When it is first allocated an initialized, it has no view object associated with it. The view is only instantiated when (and if) it is … Read more

Do I have to call addSubview after calling addChildViewController?

1) Do I have to call addSubview after calling addChildViewController? Yes 2) Do I have to call removeFromSuperview before calling removeChildViewController? Not quite You should call removeFromParentViewController: instead of removeChildViewController: You should also call willMoveToParentViewController: For adding / removing, you can refer to this great category : UIViewController + Container – (void)containerAddChildViewController:(UIViewController *)childViewController { [self … Read more

Current view controller from AppDelegate?

If your app’s root view controller is a UINavigationController you can do this: ((UINavigationController*)appDelegate.window.rootViewController).visibleViewController; Similarly, if it’s a UITabBarController you can do this: ((UITabBarController*)appDelegate.window.rootViewController).selectedViewController; Of course, explicit casting like this is dirty. Better would be to capture the reference yourself using strong types.

How to change the UINavigationController back button name?

If you wish to do this programmatically, it can be done like this: Objective-C UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@”Custom” style:UIBarButtonItemStyleBordered target:nil action:nil]; [self.navigationItem setBackBarButtonItem:backItem]; Swift let backItem = UIBarButtonItem(title: “Custom”, style: .Bordered, target: nil, action: nil) navigationItem.backBarButtonItem = backItem However, if you prefer using Interface Builder, just select the UINavigationItem that you wish to … Read more