我的问题是,我有一个ActionSheet,它只是当这个按钮下的动作完成后才从屏幕消失。我的问题是我想单击我的操作表中的'保存',然后关闭操作表,然后显示一些警报,通知用户等待直到保存完成。目前它的工作方式不同:首先显示操作表,然后在UNDER操作表中保存消息,最后将操作表从视图中删除..因此用户不会看到任何警报消息。取消actionSheet之前,它下面的动作按钮完成
如何解除actionSheet比xcode早吗? sheetActionButton下
方法:
- (IBAction)saveAction:(id)sender
{
UIAlertView *alert;
alert = [[[UIAlertView alloc] initWithTitle:@"Saving photo to library\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[alert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
[indicator release];
[self saveImageToCameraRoll];
[alert dismissWithClickedButtonIndex:0 animated:YES];
}
我已经试过你的建议修改此:dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^ {[自saveImageToCameraRoll];}); - >现在它工作完全不同,但仍然是错误的:actionSheet被解雇,但警报显示后dispatch_async完成工作o.O为什么这样..?我想要解雇actionSheet,显示警报,保存操作,关闭警报。 Atm它正在解雇actionSheet,保存行动,显示警报,甚至在代码中关闭警报,我写它不同。 – Vive
是的,就像那样。 – jtbandes
根据一些教程改变了它:dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^ { [自saveImageToCameraRoll]; dispatch_async(dispatch_get_main_queue(),完成); });完成是一个方法参数:完成:(void(^)(void))完成,我向它发送一个NULL时调用。我在之前评论中描述的问题仍然存在。 – Vive