UIAlertController设置

来源:互联网 发布:己知阴影面积为10dm 编辑:程序博客网 时间:2024/06/03 20:16
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *alertAction){
        NSLog(@"如果你是iOS8以上的应用,这个适合你,简单明了");
    }];
    [alertController addAction:cancelAction];

    [alertController addAction:okAction];


1.    [self presentViewController:alertController animated:YES completion:nil];
2.[alertController.view setNeedsLayout];

以上两个必须写一个,不然会报错:Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7f84e25b22b0>)


0 0
原创粉丝点击