mim*_*ami 3 objective-c ios 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)
处理程序是在项目选择上执行的块.
UIAlertAction *openGallery = [UIAlertAction
actionWithTitle:@"open gallery"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
// Code to run when the open gallery option is pressed.
}];
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我认为问题中长期不间断的行确实没有用,因为它们有效地隐藏了关键参数.
| 归档时间: |
|
| 查看次数: |
4184 次 |
| 最近记录: |