【发布时间】:2011-11-29 00:35:13
【问题描述】:
我正在实现一个带有活动指示器的简单警报视图,以便在应用程序执行数据库恢复时向用户显示。一切都很好,除了我看不到警报视图,除非我注释掉自动关闭行(这里的最后一个)。
好的,数据库的恢复非常快,但我仍然希望看到它,即使是一瞬间,不是吗?我可以看到在动画过程中屏幕变暗了一点,但仅此而已。我也试过放一个for循环来延长时间,时间延长了但仍然没有警报视图。
调用警报视图的方式没有任何问题,因为如果我评论解雇,我可以看到它......只有永远。有人在这里有想法吗?
在任何人说之前,我尝试将 alertView 的代表更改为 self,如 here 发布的那样,但没有帮助。
// First we prepare the activity indicator view to show progress indicator
UIActivityIndicatorView * activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activityView setFrame:CGRectMake(121.0f, 50.0f, 37.0f, 37.0f)];
[activityView startAnimating];
// Then we put it in an alert view
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Loading" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alertView addSubview:activityView];
[alertView show];
// Finally we operate the restore
[[SQLManager sharedSQL] restoreDatabase:[restoreDatabaseURL path]];
// And we can dismiss the alert view with the progress indicator
[alertView dismissWithClickedButtonIndex:0 animated:NO];
【问题讨论】:
标签: ios5 uialertview uiactivityindicatorview