[英]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.