适用于iOS 5.1及更低版本的UISplitViewController中的UIPopoverController手势处理 [英] UIPopoverController gesture handling in UISplitViewController for iOS 5.1 and below

查看:157
本文介绍了适用于iOS 5.1及更低版本的UISplitViewController中的UIPopoverController手势处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我(以及其他许多人)已经注意到Apple改变了popover控制器的外观以使用滑块窗口,而不是我使用的通常的popovertableview。虽然我对新外观感到满意,但与其他人一样,我遇到了引入滑动手势的问题:

I've (along with many others) have noticed that Apple changed the appearance of the popover controller to use a "slider" window rather than the usual "popover" tableview that I've used. While I'm okay with the new appearance, like others I'm having issues with the swipe gesture that is introduced:

iOS 5.1滑动手势被UISplitViewController劫持 - 如何避免?

对此的修复似乎是将拆分视图控制器方法presentWithGesture设置为NO。。

The fix for this seems to be to set the split view controller method "presentWithGesture" to "NO."

UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
splitViewController.presentsWithGesture = NO;

如果用户使用的是iOS 5.1,那么,如果使用iOS 5.0运行此代码,则效果很好或以下,抛出异常,因为此方法仅适用于iOS 5.1:

This works great if the user is using iOS 5.1, however, if this code is run using iOS 5.0 or below, an exception is thrown since this method is only available for iOS 5.1:

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[UISplitViewController setPresentsWithGesture:]: unrecognized selector 

是否可以不使用这种方法摆脱这种姿势,以便它向后兼容iOS5.0及以下版本?

Is it possible to get rid of this gesture without using this method so that it's backwards compatible with iOS' 5.0 and below?

推荐答案

对于任何类型的向后兼容性,首先检查是否存在新属性的setter方法...

For any type of backward compatibility, check for the presence of the setter method for the new property first...

if ([mySplitViewController respondsToSelector:@selector(setPresentsWithGesture:)]) {
    [mySplitViewController setPresentsWithGesture:NO];
}

请注意,显然你需要在添加UISplitViewController.view之前执行此操作你的窗口。我猜测在那时检查属性并添加手势识别器。如果在添加视图后更改属性,则没有明显的效果。

Note that apparently you need to do this before you add the UISplitViewController.view to your window. I'm guessing that at that point the property is examined and the gesture recognizer is added or not. If you change the property after adding the view, it has no discernible effect.

这篇关于适用于iOS 5.1及更低版本的UISplitViewController中的UIPopoverController手势处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆