UIAlertController title is always nil with iOS8

半城伤御伤魂 提交于 2019-12-13 06:58:41

问题


I have a problem since iOS8 and Xcode 6.0.1, the title of my alert dialogs doesn't appear. So I changed my UIAlertView to UIAlertController but I have the same issue...

The title of my alert is always to nil and the displaying is very ugly because I don't have the serparator lines.

Do you know why i have this ?

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];

    [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }]];

    [self presentViewController:alert animated:YES completion:nil];

But this is the result

(lldb) po alert.title
nil
(lldb) po alert.message
message

Thank you.


回答1:


I resolved my problem thanks to @Myaaoonn !

UIAlertView title does not display

I have just Remove the following method from my ViewController Category Class And its working fyn!

- (void)setTitle:(NSString *)title
{
   // My Code
}



回答2:


Try calling the UIAlertView like this:

[[[UIAlertView alloc] initWithTitle:<#title#>
                            message:<#msg#>
                           delegate:nil
                  cancelButtonTitle:<#cancel button#>
                  otherButtonTitles:<#buttons#>,nil] show];

Does the title still not show?



来源:https://stackoverflow.com/questions/26253231/uialertcontroller-title-is-always-nil-with-ios8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!