iOS 5 SDK treating UIViews differently

安稳与你 提交于 2019-12-13 13:16:13

问题


My app which use to work perfectly being compiled in xCode 4.0.2 no longer works correcly compiled in xCode 4.2 with the new SDK.

My modal views are working very different, some states not being detected, or other dismissals not working. For example this use to work to dismiss 2 stacked modal views:

if(self.parentViewController.parentViewController)
        [self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];
else
    [self dismissModalViewControllerAnimated:YES];

Now this just dismisses the first view...

I've been looking for documentation on these changes but have found none. Primary app delegate seems to be working differently too.

Help greatly appreciated.


回答1:


There is a new property in iOS 5 named presentingViewController. The meaning of parentViewController got changed a bit with the new container view controller API, so it may not always be set when you think it is. That's what presentingViewController is now for.




回答2:


if ([self respondsToSelector:@selector(presentingViewController)])
    [self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]; // for IOS 5+
} else {
    [self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES]; // for pre IOS 5
}


来源:https://stackoverflow.com/questions/7779195/ios-5-sdk-treating-uiviews-differently

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