Chr*_*ris 12 iphone objective-c uiactionsheet
如果你在外面点击它,如何让你的uiactionsheet消失?这适用于iPhone.显然,ipad默认这样做(我可能错了).
Chr*_*ris 15
好的,有一个解决方案 以下内容适用于UIActionSheet的子类
// 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];
}
Run Code Online (Sandbox Code Playgroud)
它的要点是在动作表的超视图中添加一个手势识别器,并测试所有水龙头以查看它们是否在操作表之上.
| 归档时间: |
|
| 查看次数: |
15755 次 |
| 最近记录: |