UINavigationController ios7 - NavTab in front of view - ios

I'm developing a new application to ios and i'm using UINavigationController. When i'm developing in the Xcode the view is that:
But in the simulator (iOS 7) this is the result:
And when i use iOS 6 in the simulator, this is the result:
This is my code for use UINavigationController:
RootController *controller = [[RootController alloc]init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:controller];
self.window.rootViewController = navController;

As already pointed out, a straightforward solution is adding this snippet in your viewController's viewDidLoad:
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)]) { // if iOS 7
self.edgesForExtendedLayout = UIRectEdgeNone; //layout adjustements
}

You need to set Delta of your view controller.
Switch Story board to ios6.1 or later from utility area (1st item).
Then select view of your Vc and in size inspector menu in utility area there will be delta section below frame.
There will be triangle before every delta.
Triangle y to 64 (you should be on ios6.1 or later of your storyboard).
If you need help on Deltas visit : Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?

Related

How to change the height of tab bar in iPhone X

I have an app which was previously designed in 2014. Now I have to make the app design compatible with iPhone X.
When i run the app on iPhone X simulator everything works fine except the tab bar. The tab bar height gets increased in iPhone X simulator.
I know the basic safe area guide thing but for now i don't to fill the
top and bottom empty areas, i just to display the standard tab bar as
it displays on the other iPhones.
The tab bar is added programmatically so i tried to change its height as following
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
self.tabBarController.viewControllers = [[NSArray alloc] initWithObjects:trailsNavController,mapNavController, gpsNavController,infoNavController, signUpNavController, nil];
self.tabBarController.delegate = self;
self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, self.tabBarController.tabBar.frame.origin.y, self.tabBarController.tabBar.frame.size.width, 40);
self.window.rootViewController = self.tabBarController;
The app design gets distorted when i add splash screen.
Any other way to change its height? Any help would be appreciated.
So far the only solution i know is Introducing auto layouts.
You should use proportional height. For example:
self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, self.tabBarController.tabBar.frame.origin.y, self.tabBarController.tabBar.frame.size.width, self.view.frame.size.height/6);

UINavigationController inside UIPopoverController 'Back' animations weird in Landscape

I'm stumped :-\
I have a legacy app in the store that I'm refreshing for iOS 8/9. It was written years ago (pre-ARC) and is a universal app for iPhone and iPad. Everything is now working apart from this ...
On iPad, there is a toolbar at the top of the screen from which I present UIPopoverControllers containing a UINavigationController containing some standard UITableViewController type screens you can drill down into.
In Portrait (and Portrait Upside Down) everything works as expected.
In Landscape however, pressing 'Back' (the standard back not a custom one) causes weird animations - the outgoing controller jumps outside the popover and rapidly slides offscreen (the direction being governed by which orientation the device is in) while the incoming controller simply appears instantly as soon as the outgoing controller jumps outside the popover. I had to use slow animations to determine this as at full speed it just looks like a huge glitch.
There's a short 20 second movie showing the defect here; Note what happens when tapping 'Locations' at 14 seconds in.
If, instead of a UIPopover, I present the VC stack as a form sheet, everything works as expected regardless of orientation. I've also tried the newer UIPopoverPresentationController and experienced the SAME problem, which surprised me a little.
This happens on both of the popovers I'm presenting (one from left of toolbar, one from right of toolbar) and they both have very different internals. The only common factor is that they have a UINavigationController inside a UIPopover.
I've used the view debugger to inspect the view hierarchy, but nothing seems out of the ordinary and I can't capture the view during the glitch no matter how slow I run the simulator so I suspect I'm seeing an internal issue with the popover or navigation controller.
Has anyone seen anything similar? I see this both on-device (iOS 8.4) and in Simulators for iOS 8 and 9.
For context, this project has no storyboards, rarely uses xibs and generally constructs the UI in code within loadView - it really is an old application...
Thanks for any pointers. Not sure how much any code will help here, but here's the presentation of the popover concerned;
LocationsViewController* locationsvc = [[LocationsViewController alloc] init];
UINavigationController *localNavigationController = [[UINavigationController alloc] initWithRootViewController:locationsvc];
localNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[locationsvc release];
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:localNavigationController];
aPopover.delegate = self;
aPopover.backgroundColor = [UIColor colorWithWhite:0 alpha:0.9];
self.locationPopoverController = aPopover;
[aPopover release];
[localNavigationController release];
[locationPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
I get the same defect with the following, new flavour code;
UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:locationsvc];
locationsvc.preferredContentSize = CGSizeMake(320,280);
UIPopoverPresentationController *newPresentationController;
destNav.modalPresentationStyle = UIModalPresentationPopover;
newPresentationController = destNav.popoverPresentationController;
newPresentationController.barButtonItem = sender;
destNav.navigationBarHidden = NO;
[self presentViewController:destNav animated:YES completion:nil];
And the same problem shows when I use UIModalPresentationPageSheet but NOT when I use UIModalPresentationFormSheet.
I had the same issue. The issue was fixed after I added support of landscape orientation to view controllers inside the navigation controller.
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}

Does interface builder support multiple image resolutions for different screen sizes?

The form factor button is great for testing the different iphone screen sizes, as is the assitant editor preview for older iOS version layouts.
Ofcourse if there is a background image that covers most of the screen then we need to creating tweaked images to fit the available space in each screen configuration.
Coding for it is the obvious way but working intuitively in interface builder becomes broken.
Does IB support this somehow I'm not seeing?
Well, one way of doing it is you can just load different XiBs depending on the screen size. Create two XiBs - VC1 and VC2.
You can then do this:
if([[UIScreen mainScreen]bounds].size.height == 1136) {
MyViewController *vc = [[MYViewController alloc] initWithNibName: #"VC1"];
// push vc in Navigation Controller
}
else if ([[UIScreen mainScreen]bounds].size.height == 960) {
MyViewController *vc = [[MYViewController alloc] initWithNibName: #"VC2"];
// push vc in Navigation Controller
}
Hope that helped. I've used this method before and it worked fine. Also, apologies if there are any typos in the code. Didn't type it in Xcode.

iOS 7 navigation bar of uinvigationcontroller issue

I have attached how UI looks on the different iOS versions.
This is my code below:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:contactsViewController];
[self.viewController presentModalViewController:navController animated:YES];
iOS 6
iOS 7
First problem is status bar in iOS 6 I have not status bar. Second problem is overdrawing two views. How to solve it?
You may wish to use a resizable image:
[image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
Or, as AliSoftware suggested, set the extended layout edges to UIRectEdgeNone (be sure to check if edgesForExtendedLayout is supported (your app will crash if it ties to assign this property running on iOS 6.x device):
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
I would strongly invite you to read Apple's "UI Transition Guide" which explains all these differences between iOS6 and iOS7 and how to adapt your code accordingly.
The easiest way if you want your view to still be under your statusBar even in iOS7 is to set your UIViewController's self.edgesForExtendedLayout = UIRectEdgeNone in its viewDidLoad.
You can hide the status bar in the presented viewcontroller by writing this method
- (BOOL)prefersStatusBarHidden {
return YES;
}

What causes a UIView subview to take fullscreen?

I have a project which loads a UIViewController aka appViewController to the UIWindow full screen. I then am adding another UIViewController aka menuViewController to the UIWindow. The menuViewController has a xib with a UIView with dimensions of 480 x 35. I add the menuViewController to the UIWindow like this:
MenuViewController *tempController = [[MenuViewController alloc] initWithNibName:kMenuViewController bundle:nil];
self.menuViewController = tempController;
[tempController release];
menuViewController.view.center = CGPointMake(17, 240);
[window insertSubview:menuViewController.view aboveSubview:appViewController.view];
The problem is that menuViewController is NOT respecting my center call and actually taking on fullscreen and covering my appViewController.
In Interface Builder I saw a property called: Autoresize Subviews checked for the UIWindow. I tried unchecking this and even for the subview and still does not work.
NOTES:
This project was updated from (which worked perfectly fine):
Built with: Xcode 3.x.x (forgot exact)
Base iOS: 3.0
Target iOS: 2.2
And updated to:
Built with: Xcode 4.3.1
Base iOS: Latest (5.1)
Target iOS: 4.2
Thanks!
I found that by editing the size of the view controller a few seconds after it was loaded, the problem was fixed.

Resources