小编mim*_*ami的帖子

单击按钮而不是UIAlertcontroller时创建操作

我创建两个按钮UIAlertcontroller:

One Button - "OpenCamera"
Two button - "OpenGallery"
Run Code Online (Sandbox Code Playgroud)

当我点击其中一个时,我无法理解我是如何创建动作的.

- (IBAction)takePic:(id)sender {


UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
                                                               message:nil
                                                        preferredStyle:UIAlertControllerStyleActionSheet]; // 1
UIAlertAction *openCamrea = [UIAlertAction actionWithTitle:@"open camrea"
                                                      style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                                                      }];
UIAlertAction *openGallery = [UIAlertAction actionWithTitle:@"open gallery"
                                                       style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                                                       }];

[alert addAction:openCamrea];
[alert addAction:openGallery];

[self presentViewController:alert animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios uialertcontroller

3
推荐指数
1
解决办法
4184
查看次数

标签 统计

ios ×1

objective-c ×1

uialertcontroller ×1