ios - 当用户点击 UIAlertView 的 OK 按钮时移动到另一个 View

标签 ios uialertview

当我向用户显示警报时,如果他单击“确定”按钮,我需要将他移动到另一个屏幕,我该怎么做:

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"TopStation"
                                                message :@"Your internet connection is down, you will be redirected to the previous screen"
                                                delegate:nil
                                       cancelButtonTitle:@"OK"
                                       otherButtonTitles:nil];
    [alert show];
    [alert release];

最佳答案

您需要做的是在您使用的方法中实现 UIAlertView 委托(delegate)。

所以如果你有课

@interface MyClass: UIViewController {

您需要将其更改为使用
@interface MyClass:UIViewController <UIAlertViewDelegate> {

然后在实现文件中你只需要实现方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

从那里你可以继续前进。

关于ios - 当用户点击 UIAlertView 的 OK 按钮时移动到另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6047156/

相关文章:

ios - 如何在 swift 3 中获取当前日期?

ios - Sprite 完成 Action 时调用带有 3 个参数的函数

objective-c - 将类初始化为子类

ios - 为什么 ActivityViewController 在控制台中显示自动约束错误?

ios - UIImagePickerController 显示图像慢

ios - 核心数据和 iOS 7 : Different behavior of persistent store

ios - UIAlertView 的 UIAlertViewStylePlainTextInput 自定义字体在 iOS 中不起作用

ios - 将信息传递给 UIAlertView 委托(delegate)

ios - UIAlertController/ActionSheet 在 iPad 上崩溃,如何传递发件人?

ios - 自动关闭 UIAlertView 后导航栏色调颜色发生变化