【发布时间】:2011-06-22 19:16:33
【问题描述】:
我试图让当用户按下标签栏项目时 UIAlertView 被调用,询问是否真的想要更改实际标签,问题是 UIAlertView 在得到答案之前不会停止代码,代码继续运行,并根据之前的值更改视图控制器,而不是实际的。
我试图等待一段时间的答案,但屏幕只会变暗并且没有弹出警报。我也看了这篇帖子pause code execution until UIAlertview,我试过了,但我无法让它工作,谁能帮忙,谢谢!
- (BOOL) tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
if (([self Myfunction]) && (viewController != [tabBarController.viewControllers objectAtIndex:0])){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"text1" message:@"text2" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
return boolean_var;
}
return YES;}
- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) [self setBoolean_var:NO];
else [self setBoolean_var:YES];}
【问题讨论】:
-
老兄,你在这个问题上打败了我......谢谢!
标签: iphone uialertview uitabbar