iOS 5 SDK treating UIViews differently

2019-06-25 06:40发布

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.

2条回答
Luminary・发光体
2楼-- · 2019-06-25 06:48

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.

查看更多
萌系小妹纸
3楼-- · 2019-06-25 07:11
if ([self respondsToSelector:@selector(presentingViewController)])
    [self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]; // for IOS 5+
} else {
    [self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES]; // for pre IOS 5
}
查看更多
登录 后发表回答