2 sinat 36062173 sinat_36062173 于 2016.09.08 09:10 提问

IOS的警告框与页面跳转

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

5个回答

hi_chen_xingwang
hi_chen_xingwang   Rxr 2016.09.08 18:01

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

u013026165
u013026165   2016.09.27 16:26

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

u012877287
u012877287   2016.10.08 16:00

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

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

记得准守协议和赋上代理

Soar2
Soar2   2016.10.10 11:27

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

qq_36634059
qq_36634059   2016.11.07 10:31

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
上传中...
上传图片
插入图片