Kal*_*494 2 user-interface swift uialertcontroller
在我的应用程序中,在呈现UIAlertController它时将消息截断为一行.如何使用自动换行显示全文显示.
这是我的代码
let alert = UIAlertController(title: title, message:"Long text" ,
preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction(title: "OK", style:
UIAlertActionStyle.default, handler: nil)
alert.addAction(okAction)
self.present(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
小智 6
我最近几天也面临同样的问题,但终于找到了解决方案。我删除了“使用 UIEdgeInsets 填充”代码,它工作正常。
删除了下面的代码
extension UILabel {
public var padding: UIEdgeInsets? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.padding) as? UIEdgeInsets
}
set {
if let newValue = newValue {
objc_setAssociatedObject(self, &AssociatedKeys.padding, newValue as UIEdgeInsets, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
UIAlertviewController。希望会有所帮助!!!
小智 -1
在字符串中,您可以使用“\n”手动添加多行
let string = "This is \na string with \nmultiple lines"
Run Code Online (Sandbox Code Playgroud)
应该给你一个总共 3 行的字符串。
| 归档时间: |
|
| 查看次数: |
2567 次 |
| 最近记录: |