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?

Felix
  • 35,354
  • 13
  • 96
  • 143
  • 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. – Joe Strout Dec 03 '13 at 22:58
  • Have you tried reporting this as a bug? – Radu Simionescu Jul 09 '14 at 11:51
  • possible duplicate of [UINavigationItem Prompt Issue](http://stackoverflow.com/questions/22115821/uinavigationitem-prompt-issue) – elcuco Aug 06 '14 at 13:34

1 Answers1

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.

dtim
  • 31
  • 2
  • Yeah, that is the same what I did. There must be a better way. – Felix Sep 27 '13 at 18:00
  • 2
    ...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). – Joe Strout Dec 03 '13 at 23:03
  • @JoeStrout try to nil out the prompt in the master's viewWillAppear – Felix Dec 04 '13 at 10:10