gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:33:02 24 4
gpt4 key购买 nike

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

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com