【发布时间】:2013-07-25 11:45:12
【问题描述】:
我正在创建随机数量的同一类的自定义 UIView,并将它们添加到 UIViewController 的视图中。我正在为他们分配一个 UITapGestureRecognizer,但我似乎无法使独家触摸工作:
for (int i = 0; i <= n; i++) {
ICCatalogProductView *catalogProductView;
catalogProductView = [[ICCatalogProductView alloc] init];
[self.view addSubview:catalogProductView]
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(testTouch)];
[catalogProductView addGestureRecognizer:tapGesture];
[catalogProductView setExclusiveTouch:YES];
}
如果我同时点击 UIViews,该方法会被调用两次(不是我想要的行为)。有什么优雅的方法可以解决这个问题,或者有什么方法吗?
【问题讨论】:
-
同时选项卡上实际需要的内容。请说明。
-
我只希望有一个触摸是可能的,当有 2 个 UIButtons 和 .exclusiveTouch = YES 时,你会有同样的行为