Iphone 触摸屏不';t显示突出显示,TapGestureRecognitor
我有一组按钮,它们有一个链接到它们的TapGestureRecognitor,这将执行适当的操作 由于我有这么多按钮,我不想通过iAction手动链接它们 现在我遇到的问题是,它不会立即显示ShowTouchonHighlight。我不知道如何修复此问题,以下是我使用的代码:Iphone 触摸屏不';t显示突出显示,TapGestureRecognitor,iphone,ios,xcode,cocoa-touch,Iphone,Ios,Xcode,Cocoa Touch,我有一组按钮,它们有一个链接到它们的TapGestureRecognitor,这将执行适当的操作 由于我有这么多按钮,我不想通过iAction手动链接它们 现在我遇到的问题是,它不会立即显示ShowTouchonHighlight。我不知道如何修复此问题,以下是我使用的代码: - (void)tapPress:(UITapGestureRecognizer *)sender { UIButton *resultButton = (UIButton *)sender.view;
- (void)tapPress:(UITapGestureRecognizer *)sender {
UIButton *resultButton = (UIButton *)sender.view;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:[NSBundle bundleForClass:[self class]]];
infoView *infoViewController = [storyboard instantiateViewControllerWithIdentifier:resultButton.currentTitle];
infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:infoViewController
animated:YES
completion:nil];
}
尝试使用
addTarget:action:forControlEvents:
方法为每个按钮设置目标和操作,而不是使用点击手势识别器。这将节省您连接笔尖上每个按钮的工作量。我不明白。为什么你要使用点击手势识别器而不是仅仅使用按钮的触碰内部事件?因为我有38个按钮,我可以轻松创建一个手势识别器,而不是通过界面构建器链接所有按钮。你是否在代码中创建手势识别器?您可以使用addTarget:action:forControlEvents:
消息在代码中设置按钮的目标和操作。是的,但问题是,当用户按下按钮时,它不会显示touchOnHighlight,只有当用户按住按钮半秒钟后,它才会显示出来。我知道,使用轻触手势识别器时,它会延迟touchOnHighlight效果。如果使用addTarget:action:forControlEvents:
且不使用手势识别器,是否会延迟touchOnHighlight效果?