iphone - 显示警报 View 后如何移动到下一个 View Controller

标签 iphone xcode

我有 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/

相关文章:

iphone - 使用本地时区将 unix 时间戳转换为 NSdate

iphone - 在 iPhone 应用程序中从谷歌驱动器下载图像

iphone - 如何在 iOS 中更改键盘背景颜色?

ios - 来自 Crashlytics 的 EXC_BAD_ACCESS KERN_INVALID_ADDRESS 错误崩溃

ios - SpriteKit 中的毛玻璃效果?

ios - 解析 json 并出现异常,原因 : '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x7b1c7630

iphone - MKAnnotationViews 的 Z 排序

javascript - 将 javascript 放入 xcode 项目的更好方法

ios - 创建一个内部有 2 个 UiView 的水平 Stackview

objective-c - 使用带有 Storyboard的 instantiateViewControllerWithIdentifier 传递属性值