我想在操作表上设置操作,这样当用户点击操作表上方时它会被取消。
我想这样做是因为我不想在操作表中添加取消按钮。用户可以通过点击休息区 View 来取消操作表,而不是取消按钮。
关于如何在 iPhone 中执行此操作的任何建议。
谢谢
最佳答案
// For detecting taps outside of the alert view
-(void)tapOut:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint p = [gestureRecognizer locationInView:self];
if (p.y < 0)
{ // They tapped outside
[self dismissWithClickedButtonIndex:0 animated:YES];
}
}
-(void) showFromTabBar:(UITabBar *)view
{
[super showFromTabBar:view];
// Capture taps outside the bounds of this alert view
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOut:)];
tap.cancelsTouchesInView = NO; // So that legit taps on the table bubble up to the tableview
[self.superview addGestureRecognizer:tap];
[tap release];
}
参见 here .
请注意,这已经发生在 iPad 上。
关于iphone - 当用户点击 iPhone 中的上方 View 时隐藏 UIActionSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8683752/