iOS 7 detail layout when master has navigation bar prompt
Asked Answered
C

1

5

I run into a layout problem in iOS 7:

Screenshot

To reproduce create a simple master-detail-app and insert this line in MasterViewController.m :

self.navigationItem.prompt = @"Master";

and this in DetailViewController.m :

self.edgesForExtendedLayout = UIRectEdgeNone;

Both lines in viewDidLoad.

The detail view's frame does not update correctly when the navigation bar shrinks to its normal size.

How should I fix this?

Confucian answered 13/9, 2013 at 8:56 Comment(3)
The same problem occurs in the other direction: if the detail has a prompt and the master doesn't, then when the detail view is popped, the master ends up with an ugly black bar below the nav bar.Stambul
Have you tried reporting this as a bug?Ardeliaardelis
possible duplicate of UINavigationItem Prompt IssueCampuzano
A
3

My current solution to this is to remove the prompt in the master view's viewWillDisappear:

- (void) viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationItem.prompt = nil;
}

Then just set it again in the viewWillAppear. There should be a better method, however.

Austronesia answered 27/9, 2013 at 15:59 Comment(3)
Yeah, that is the same what I did. There must be a better way.Confucian
...and, this work-around doesn't appear to work when set up the other way (i.e. when it's the detail that has the prompt, and we put this code in the detail's viewWillDisappear).Stambul
@JoeStrout try to nil out the prompt in the master's viewWillAppearConfucian

© 2022 - 2024 — McMap. All rights reserved.