小编gho*_*osh的帖子

如何处理UIAlertController的操作?

如何使用objective-c将UIAlertController警报操作按钮与操作处理程序链接?我正在使用Xcode 7.1.

这是我的代码:

- (IBAction)selectbtn:(UIButton *)sender {

    UIAlertController *alert=[ UIAlertController alertControllerWithTitle:@"NEW" message:@"button pressed" preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *cameraaction=[UIAlertAction actionWithTitle:@"From camera" style:UIAlertActionStyleDefault handler:nil ];
    [alert addAction:cameraaction];
    UIAlertAction *libraryaction=[UIAlertAction actionWithTitle:@"From photo library" style:UIAlertActionStyleDefault handler:nil ];
    [alert addAction:libraryaction];
    UIAlertAction *cancelaction=[UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDestructive handler:nil];
    [alert addAction:cancelaction];
    [self presentViewController:alert animated:YES
                     completion:nil];
    }
Run Code Online (Sandbox Code Playgroud)

objective-c ios uialertcontroller

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios ×1

objective-c ×1

uialertcontroller ×1