UISplitView new slide-in popover becomes fullscreen after memory warning in iOS 5.1

◇◆丶佛笑我妖孽 提交于 2019-12-19 03:20:09

问题


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!


回答1:


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.




回答2:


I had the same trouble.

You should add below code to AppDelegate.

splitViewController.presentsWithGesture = NO;



来源:https://stackoverflow.com/questions/9649608/uisplitview-new-slide-in-popover-becomes-fullscreen-after-memory-warning-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!