Shared iAd banner for UITabBarController based app using XCode 4 with storyboard

It’s fairly simple actually. Just create a new banner view controller for each tab that will be the parent view controller for each tab in your storyboard. Then drag in a Container View object into each banner view controller and embed your child view controllers in each banner view controller. Finally in BannerViewController.m replace the … Read more

Present a modal view controller with transparent background

Suppose, we’re in FirstViewController //Obj-C – (void) presentSecondVC { SecondViewController *vc = [[SecondViewController alloc] init]; [self addChildViewController:vc]; [self didMoveToParentViewController:vc]; } //Swift func presentSecondVC() { let vc = SecondViewController.init() self.addChildViewController(vc) self.didMove(toParentViewController: vc) } Some of you may need to write above method like this, //Obj-C – (void) presentSecondVC { SecondViewController *vc = [[SecondViewController alloc] init]; vc.view.frame … Read more

How to prevent status bar from overlapping content with hidesBarsOnSwipe set on UINavigationController?

Actually it is pretty easy to do. You just need to connect navigation isNavigationBarHidden property with status bar. Objective-C – (BOOL)prefersStatusBarHidden { return self.navigationController.isNavigationBarHidden; } Swift <= 2.3 override func prefersStatusBarHidden() -> Bool { return navigationController?.navigationBarHidden ?? false } Swift 3.0 override var prefersStatusBarHidden: Bool { return navigationController?.isNavigationBarHidden ?? false } And be sure you … Read more

iOS 13 UIBarButtonItem not clickable and overlapping UINavigationBars when using UISearchController

The view debugger reveals what’s going on with this bug. The contents of the navigation bar are being copied. Here’s what the navigation bar looks like before you show the search: And here’s what it looks like afterwards: The two replicant views and the extra UILabel are the problem. I don’t know what they’re doing … Read more

Push ViewController from Right To Left with UINavigationController

You can create a NSMutableArray from the navigationController’s array of viewcontrollers and insert new viewController before the current one. Then set the viewControllers array without animation and pop back. UIViewController *newVC = …; NSMutableArray *vcs = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; [vcs insertObject:newVC atIndex:[vcs count]-1]; [self.navigationController setViewControllers:vcs animated:NO]; [self.navigationController popViewControllerAnimated:YES];

how to hide navigationbar when i push from navigation controller?

Put this code in the view controller you want to hide the navigation bar for. – (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:animated]; } And you may also want to stick this in there, depending on your needs: – (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO animated:animated]; }

iOS how to detect programmatically when top view controller is popped?

iOS 5 introduced two new methods to handle exactly this type of situation. What you’re looking for is -[UIViewController isMovingToParentViewController]. From the docs: isMovingToParentViewController Returns a Boolean value that indicates that the view controller is in the process of being added to a parent. – (BOOL)isMovingToParentViewController Return Value YES if the view controller is appearing … Read more

Is there a way to change the height of a UINavigationBar in Storyboard without using a UINavigationController?

You can set the property barPosition to UIBarPositionTopAttached another way! Add a delegate to your UINavigationBar. Implement -positionForBar: in the delegate class: – (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { return UIBarPositionTopAttached; } Your navigation bar’s top must also be anchored to the Top Layout Guide.