29,027
社区成员
发帖
与我相关
我的任务
分享
#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];
}