我正在从 UIActionSheet 的 clickButtonAtIndex 函数启动 UIActivityIndicator。这是代码
+(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"AS Button Clicked %d",buttonIndex);
UIActivityIndicatorView *indicator=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.frame=CGRectMake(10, 10, 56, 56);
[indicator startAnimating];
[[actionSheet superview] addSubview:indicator];
}
下面给出了启动 UIActionSheet 的代码
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil
delegate: self
cancelButtonTitle: nil
destructiveButtonTitle: @"Cancel"
otherButtonTitles: @"Button1",
@"Button2", nil];
[actionSheet showFromRect: rect inView: view animated: YES];
但是,单击按钮的那一刻,UIActivityIndicator 与 UIActionSheet 一起消失。
我在这里想念什么?
最佳答案
操作表的 super View 要么是一个新窗口,要么是覆盖屏幕的其他 View 。当您关闭操作表时,也会删除此其他窗口或 View 。
由于您将事件指示器添加到此其他 View ,因此事件指示器与操作表的其余部分一起消失。
您需要将事件指示器添加到与操作表无关的内容。
关于ios - 一旦 actionSheet 关闭,UIActivityIndicator 就会消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18397330/