【问题标题】:UIAlertController title is always nil with iOS8iOS8 的 UIAlertController 标题始终为零
【发布时间】:2014-10-08 09:14:36
【问题描述】:

我从 iOS8 和 Xcode 6.0.1 开始遇到问题,我的警报对话框的标题没有出现。所以我将我的 UIAlertView 更改为 UIAlertController 但我有同样的问题......

我的警报标题总是 nil 并且显示非常难看,因为我没有分隔线。

你知道我为什么会有这个吗?

    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];

但这就是结果

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

谢谢。

【问题讨论】:

  • 使用 Excat 相同的代码并在这里工作
  • @Bhumit 我在另一个干净的项目上进行了测试,它也可以正常工作,但我不知道在我的实际项目中可能与 UIAlertController 有什么冲突...
  • 它在我身边工作
  • @Varsha 我也有一个新项目,但不是我当前的项目。我不知道为什么:/

标签: ios ios8 uialertview uialertcontroller


【解决方案1】:

感谢@Myaaoonn,我解决了我的问题!

UIAlertView title does not display

我刚刚从我的 ViewController 中删除了以下方法 类别类及其工作方法!

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

【讨论】:

    【解决方案2】:

    尝试像这样调用 UIAlertView:

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

    标题还没有显示吗?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 2012-01-16
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多