1
我有一堆tapGestureRecognizer链接到它们的按钮,并且这会执行相应的操作。触摸不显示高亮,tapGestureRecognizer
由于我有这么多的按钮,我不想通过IBAction手动链接它们。
现在我收到的问题是,它没有立即显示showsTouchOnHighlight。我不知道如何解决这个问题,这里是我使用的代码:
- (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];
}
我不明白。为什么使用轻击手势识别器而不是仅使用按钮的touchUpInside事件? –
,因为我有38个按钮,我可以轻松创建手势识别器,而不是通过界面生成器链接所有按钮。 –
您是否在代码中创建手势识别器?您可以使用'addTarget:action:forControlEvents:'消息在代码中设置按钮的目标和操作。 [Documentation](http://developer.apple.com/library/ios/documentation/uikit/reference/UIControl_Class/Reference/Reference.html#//apple_ref/occ/instm/UIControl/addTarget:action:forControlEvents :) –