UISplitView new slide-in popover becomes fullscree

2019-02-13 22:05发布

I'm quite new here. I have a problem with the new iOS 5.1 slide-in popover in UISplitView. (Before 5.1 the master view controller was presented in a popover, but now it simply slides in form the left.) When my device is in portrait mode and it receives a memory warning, the master view controller unloads; and when I press the toolbar button to slide in the master view, it loads again. However after the memory warning it is presented in fullscreen and not only the size of the original master view. (When I rotate the device to landscape and back to portrait, it gets its correct size back.)

Before iOS 5.1 it was always presented in the popover with the correct size.

Anyone has an idea, how to correct this?

I've tried to set the master view's frame size, but it doesn't solve the problem.

Any help is much appreciated!

2条回答
不美不萌又怎样
2楼-- · 2019-02-13 22:43

I had the same trouble.

You should add below code to AppDelegate.

splitViewController.presentsWithGesture = NO;

查看更多
三岁会撩人
3楼-- · 2019-02-13 22:50

I had the same problem, but I used this code to solve the problem:

-(void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController
{
    aViewController.view.frame = CGRectMake(0, 0, 320, self.view.frame.size.height);
}

Apparently when a memory warning is received, the view controller gets released, so when it presents itself again, it gets it's size from it's parent view, which is full screen. So you just have to reset the frame every time it gets loaded.

查看更多
登录 后发表回答