‘UIAlertController’没有可见的@interface声明选择器‘initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:’

问题描述 投票:0回答:1
    UIAlertController *alert = [[UIAlertController alloc] initWithTitle: alertString message:nil
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];

我遇到了这个错误:

No visible @interface for 'UIAlertController' declares the selector 'show'

还有这个:

‘UIAlertController’没有可见的@interface声明选择器‘initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:’

ios objective-c
1个回答
1
投票

声明步骤正确

UIAlertController

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];

// add action button
UIAlertAction *okAction = [UIAlertAction actionWithTitle:actionTitle style:UIAlertActionStyleDefault handler:nil];

[alertController addAction:okAction]; // add action button to alert controller



// present alert controller in view
[self presentViewController:alertController animated:YES completion:nil];
© www.soinside.com 2019 - 2024. All rights reserved.