有人可以帮我解决这个错误

时间:2016-10-16 08:27:49

标签: ios objective-c

    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'

并且:No visible @interface for 'UIAlertController' declares the selector 'initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:'

1 个答案:

答案 0 :(得分: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];