Home Title and Navigation bars white in iOS 11 on view using ABNewPersonViewController
Reply: 1

Title and Navigation bars white in iOS 11 on view using ABNewPersonViewController

Dave4988
1#
Dave4988 Published in 2017-11-14 20:34:20Z

I've inherited a legacy app and was tasked with updating it for iOS 11. In one view, the user can click on a name and add that user to their contacts. However, when going to the 'add contact' view in iOS 11, the navigation and status bars are showing up as white. It works fine on iOS 10 and below.

Here's a screenshot comparing iOS 10 (left) to iOS 11 (right):

Note that this view is created programmatically, and not through the storyboard:

ABRecordRef person = ABPersonCreate();
//...
ABNewPersonViewController *newPersonViewController = [[ABNewPersonViewController alloc] init];
[newPersonViewController setDisplayedPerson:person];
newPersonViewController.newPersonViewDelegate = self;
UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:newPersonViewController];
[self presentViewController:newNavigationController animated:YES completion:nil];
CFRelease(person);

I've tried a few different things based on what I found online:

  1. I found I can manually set the background color of the navigation bar, but that leaves the status bar white.
  2. I've tried adding a HeightConstraint to the new view. I confirmed the constraint is added, but it didn't help. However, I had to set the value with a constant (tried 0, 100, 1000 just for testing) and couldn't get the relative constraint working properly. Regardless, not sure if it was worth going down that path.
  3. I saw some articles online that iOS 11 changes how the status/nav bars work and recommended setting setContentInsetAdjustmentBehavior to NEVER. However, this looks like it only works on ScrollViews or TableViews. This contact add view appears just to be a UIView.
  4. Tried switching to CNContactViewController (as ABNewPersonViewController is deprecated), and ran into the same issue.

Any advice would be helpful.

Edit: The Navigation bar colors get set in the AppDelegate in the didFinishLaunchingWithOptions method as seen below. I tried removing all the custom logic that gets set here. This somewhat fixed the navigation bar, but the status bar was still white with white text.

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

if ([MPUtils isIOS7OrHigher]) {
    [[UIToolbar appearance] setBarTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
    [[UINavigationBar appearance] setBarTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];

    //color of text on buttons:
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}];
} else {
    [[UIToolbar appearance] setTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
    [[UINavigationBar appearance] setTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
}

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

[MPUserDataSynchronizer syncUserData];

return YES;
}
Santhosh R
2#
Santhosh R Reply to 2017-11-14 20:40:34Z

ABNewPersonViewController is deprecated in iOS 9. Use CNContactViewController instead.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.350807 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO