您的位置:首页 > 产品设计 > UI/UE

UIAlertController设置

2016-05-03 09:37 621 查看
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>)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: