为什么检查UIGestureRecognizer在iPhone OS 3.0上找到它,当它在3.2中引入时?

Tzu*_*zit 1 iphone cocoa-touch iphone-sdk-3.0 uigesturerecognizer

我第一次使用UIGestureRecognizer,我想让我的应用程序在iOS 3.0上运行.由于Apple明确表示该库在iOS 3.2及更高版本中可用,因此我使用了以下代码:

// Make sure that Gesture recognition technology is supportted by the device SDK version
if ([UIGestureRecognizer instancesRespondToSelector:@selector(initWithTarget:action:)])
{
    [self initGestureRecognizers];
}
Run Code Online (Sandbox Code Playgroud)

令人惊讶的是,当我在我唯一的目标上运行App时,运行SDK3.0,它运行正常.


我将条件替换为以下内容:

if ([[[UIDevice currentDevice] systemVersion] compare:@"3.2"] != NSOrderedAscending) 
{ 
    [self initGestureRecognizers]; 
}
Run Code Online (Sandbox Code Playgroud)

我很想得到关于它的评论.

谢谢

Joh*_*ool 5

这可能是因为UIGestureRecognizer在3.2之前被认为是私有的.如果在3.0下使用UIGestureRecognizer,如果有些东西有问题或者没有按预期工作,请不要感到惊讶.