UIAlertController不显示多行消息

时间:2018-07-03 12:47:56

标签: ios swift xcode

我正在使用IOS应用程序,我一直在使用Web服务获取和发送数据。有时我需要显示消息,例如带有详细信息的错误消息。因此,我一直在使用以下消息向用户显示警报。完美

let alertController = UIAlertController(title: ""+title, message: ""+msg, preferredStyle: UIAlertControllerStyle.alert)
alertController.addAction(UIAlertAction(title: ""+txtBtnPositive, style: UIAlertActionStyle.default, handler: { (action: UIAlertAction!) in
    if(shouldExitScreen){
        self.navigationController!.popViewController(animated: true)

        self.dismiss(animated: true, completion: nil)
    }
}))

self.present(alertController, animated: true, completion: nil)

这是一个运行良好的代码段。如果长消息很长,则会在多行显示。单行消息没有问题。

但是突然之间,UiAlertController在一行中显示长消息,并从尾部将其截断。但是我没有在代码中进行更改。我不知道为什么会这样。有什么提示吗?

1 个答案:

答案 0 :(得分:1)

UIAlertController无法像您所说的那样工作。由于其默认行为是在UiLabel中以多行和中心对齐方式显示文本。

我怀疑您是否已使用扩展程序(如Kamran在评论中所示)。可能是代理服务器(扩展名)可能正在更改其默认行为。

快速查看您的扩展,看看是否对UiLabel有任何影响。如果UILabel上有任何代理,那将是罪魁祸首。