iOS 7 detail layout when master has navigation bar

2019-04-30 09:11发布

问题:

I run into a layout problem in iOS 7:

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?

回答1:

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.