IOS的警告框与页面跳转

IOS里面如何实现点击警告框中的按钮,然后跳转到另一个页面(viewcontroller)

5个回答

AlertViewController /UIAlertView 服从代理写方法去跳转就可以

//这是只有取消和确定按钮的alertView的代理方法的实现
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView == self.logoutAlertView) {
if (buttonIndex == 0) {
debugLog(@"取消");
//取消跳转
}
if (buttonIndex == 1) {
debugLog(@"确定");
//确定,然后在这里面实现跳转的事件
}
}
}

UIActionSheet *actionS = [[UIActionSheet alloc]initWithTitle:@"标题" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"跳转到页面一",@"跳转到页面二",@"跳转到页面3", nil];
[actionS showInView:self.view];

再抄上楼二楼的 基本就够了

记得准守协议和赋上代理

楼上说的方法差不多就可以实现了!

UIAlertController,在确定的block块里,实现页面跳转
代码如下:

 - (void)showOkayCancelAlert {
    NSString *title = NSLocalizedString(@"A Short Title Is Best", nil);
    NSString *message = NSLocalizedString(@"A message should be a short, complete sentence.", nil);
    NSString *cancelButtonTitle = NSLocalizedString(@"Cancel", nil);
    NSString *otherButtonTitle = NSLocalizedString(@"OK", nil);

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];

    // Create the actions.
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"The \"Okay/Cancel\" alert's cancel action occured.");
    }];

    UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSLog(@"The \"Okay/Cancel\" alert's other action occured.");
    }];

    // Add the actions.
    [alertController addAction:cancelAction];
    [alertController addAction:otherAction];

    [self presentViewController:alertController animated:YES completion:nil];
}

大神问答,程序员专用问答网站,又快又准找到问题答案!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问