UIAlertController

Posted 王权

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UIAlertController相关的知识,希望对你有一定的参考价值。

技术分享

    UIAlertController * alert =[UIAlertController alertControllerWithTitle:@"新建相册" message:@"请输入新建相册的名字" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

    }];

    

    UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

    }];

    

    [alert addAction:cancelAction];

    [alert addAction:otherAction];

    [alert addTextFieldWithConfigurationHandler:nil];

 

    [self presentViewController:alert animated:YES completion:nil];

 

技术分享

 

    UIAlertController * alert =[UIAlertController alertControllerWithTitle:@"选择方式" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

 

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

    }];     

    UIAlertAction *photoLibraryAction = [UIAlertAction actionWithTitle:@"从相册读取" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

    }];

    UIAlertAction *takePhotoAction = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

    }];

 

    [alert addAction:cancelAction];

    [alert addAction:takePhotoAction];

    [alert addAction:photoLibraryAction];

    

    [self presentViewController:alert animated:YES completion:nil];

以上是关于UIAlertController的主要内容,如果未能解决你的问题,请参考以下文章