[英]UIActionSheet pass touches through?
我正在寻找一种类似于上下文消息框的UIActionSheet
(根本没有任何操作按钮,只是气泡中的标签带有指向某物的箭头)。 由于用户无法执行任何操作,因此我希望它不需要轻按即可关闭,但是我看不到任何允许这样做的方法(例如passthroughViews
属性)。
它可能不是为此设计的,但是它确实很方便。
这是一些示例代码,显示如何显示UIAlertView并自动将其关闭。
展示下:
- (void)show
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"title"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
alert.tag = tag;
[alert show];
}
将其关闭:
- (void)dismiss
{
for (UIWindow* w in [UIApplication sharedApplication].windows)
for (NSObject* o in w.subviews)
if ([o isKindOfClass:[UIAlertView class]]) {
UIAlertView *alert = (UIAlertView*) o;
if (alert.tag == tag)
[alert dismissWithClickedButtonIndex:[(UIAlertView*)o cancelButtonIndex] animated:YES];
}
}
您可以在几秒钟后调用dismiss方法:
[self performSelector:@selector(dismiss) withObject:nil afterDelay:1.0 inModes:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.