UIAlertController title is always nil with iOS8

2019-09-06 15:48发布

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

Alertview without title

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

Thank you.

2条回答
来,给爷笑一个
2楼-- · 2019-09-06 16:26

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?

查看更多
ゆ 、 Hurt°
3楼-- · 2019-09-06 16:31

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
}
查看更多
登录 后发表回答