I'm updating app from iOS 4.3 to iOS 7 and I cannot fix one issue. I did lots of searches online but with no luck. There are similar problems but it doesn't work for me:
I don't use storyboard, I use xib files. I have view controller embedded in nav controller embedded in tab bar controller. I add my views in didFinishLaunchingWithOptions: method like that:
HomeViewController *homeViewController = [[HomeViewController alloc] init];
homeViewController.tabBarItem.image = [UIImage imageNamed:@"home.png"];
homeViewController.tabBarItem.title = NSLocalizedString(@"Home", @"Home");
UINavigationController *homeNavController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
homeNavController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
//...other views
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:homeNavController, ..., nil];
To add custom background image I use code (still in the same method):
[[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xFFA722)];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"Logo.png"] forBarMetrics:UIBarMetricsDefault];
I try add UINavigationBarDelegate and:
- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
But when I set the delegate, I try to do it in two ways:
//in didFinishLaunchingWithOptions
homeNavController.navigationBar.delegate = self;
of in view controller:
self.navigationController.navigationBar.delegate = self;
The error appears:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot manually set the delegate on a UINavigationBar managed by a controller.'
Do you know how can I fix this issue to have nav bar layout right on the top without override status bar?
The other issue is that I have image Logo with size 320x44 and retina version 640x88 in my app the image is being repeated. Why is like that it has exact size as nav bar? Thanks in advance.