问题:现在已升级到更新的Xcode并支持ios 11。 (我的应用程序不需要它,但是由Apple强迫不再支持界面构建器文件-尝试将应用程序上载到应用程序商店时收到错误消息)。

该代码似乎很简单(并非总是如此!)。
我创建了一个示例(最小示例)并将其附加。
简单的单页应用程序。加载视图并识别一些手势。
因此,单击手势有效。双击不。
双击被识别为2个单点(可能是合理的)。
我删除了一次点击获取,并尝试触发2手指2轻拍手势的处理程序。
不被认可。
都使用空的nib文件为ios5.x工作。

这是appDelegate文件:

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

实施:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds] ;
    self.appViewController = [[myViewController alloc] initWithNibName:nil bundle:nil];
    self.window.rootViewController = self.appViewController;
    //@property(nullable, nonatomic,strong) UIViewController *rootViewController NS_AVAILABLE_IOS(4_0);  // from "UIWindow"

    [self.window makeKeyAndVisible];
    self.window.backgroundColor = [UIColor redColor];

    return YES;
}

ViewController:
@interface ViewController ()
@property (retain,readwrite) UITapGestureRecognizer       *twoFingerDoubleTap_yyz;
@property (retain,readwrite) UITapGestureRecognizer       *oneFinger;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    //add gesture Double tap to open a view.

    self.twoFingerDoubleTap_yyz = [[UITapGestureRecognizer alloc]initWithTarget:(id)self action:@selector ( twoFingerDoubleTap:) ];
    [self.view addGestureRecognizer:self.twoFingerDoubleTap_yyz];
    self.twoFingerDoubleTap_yyz.numberOfTapsRequired = 2;
    self.twoFingerDoubleTap_yyz.numberOfTouchesRequired = 2;

    /*
    self.oneFinger = [[UITapGestureRecognizer alloc]initWithTarget:(id)self action:@selector ( oneFingerTap:) ];
    [self.view addGestureRecognizer:self.oneFinger];
    self.oneFinger.numberOfTapsRequired = 1;
    self.oneFinger.numberOfTouchesRequired = 1;
*/
}


-(IBAction)twoFingerDoubleTap:        (UITapGestureRecognizer *) sender
{
    NSLog(@"i'm here 2 !");
}

-(IBAction)oneFingerTap:        (UITapGestureRecognizer *) sender
{
    NSLog(@"i'm here 1 !");
}

@end

代码似乎很简单,所以我想将问题归咎于Xcode(也许新的9.1无法识别双击?)或ios11。但是由于我没有看到其他人遇到这个问题,所以我不得不认为我缺少了一些东西-甚至很明显?
(注意:我还没有在真正的设备上尝试过,因为此时没有比ios7.x更多的东西运行了。我的原始iPad需要升级-最后!!)

更新:(因为它非常相关,所以从注释部分移到了这里,因为它非常相关),两指单击也可以在测试中使用。只是不是两指双击!

最佳答案

经过进一步测试,我得出结论,模拟器是罪魁祸首。通常,要模拟2个手指,请按下选项键。以前的模拟器一切正常。在此模拟器中,在第一次点击之后,对选项键的按住是“撤消”。
过去,我可以按住Option键并双击键盘。不适用于Xcode 9.1。
变通方法:(较难执行/使用)是尝试同时双击选项键和键盘。要做起来要困难得多,所以测试很不方便。
我提出了一个苹果错误报告,现在将使用此信息对其进行更新。错误号:#35671917
(是否可以查看该网站上的错误(其他人),或者是“只写”隐藏所有问题的网站?)

进一步说明:我也确认在使用ios9.3.5的真实设备上运行时没有问题。手势都被认为是预期的。

更新:

苹果声称这是现有错误的重复,(尽管我们无法知道,因为它是一个最高机密的数据库,所以世界无法浏览(您自己的问题报告除外),但可以添加记录)可能正在解决问题或可能没有解决-他们不会泄露此类信息。

关于ios - 无法识别手势(两指双击):Xcode 9.1,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47464168/

10-13 05:05