我有 iPhone,我希望当显示 AlertView
且用户按下 OK 按钮后,该 View 应该更改,但它没有发生。
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thank you" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return;
[self moveToView];
-(void)moveToView
{
MainViewController*targetController=[[MainViewController alloc]init];
[self.navigationController pushViewController:targetController animated:YES];
}
最佳答案
请使用UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
// Code to move to next view
[self moveToView];
}
注意:在界面声明中实现UIAlertViewDelegate
。另外,在声明 UIAlertView 时将委托(delegate)设置为 self。
希望这对您有帮助。
关于iphone - 显示警报 View 后如何移动到下一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11411316/