viewcontroller present AlertController 点击cancel后调用了viewcontroller重写的dismiss

kane313 2017-11-16 11:44:09
viewControllerA present ViewControllerB 在B中点击按钮present alertController 点击cancel按钮后调用了B中重写的- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion 请问这是为什么?

#import "testViewController.h"

@interface testViewController ()

@end

@implementation testViewController

- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"button" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button.frame = self.view.bounds;
// Do any additional setup after loading the view.
}
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion{
//这里在点击alertController上的cancel按钮会被执行
[super dismissViewControllerAnimated:flag completion:completion];
}
- (void)buttonAction{
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"awdad" message:@"dawwaea" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* action = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:action];
[self presentViewController:alertController animated:YES completion:nil];
}
...全文
222 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧