gpt4 book ai didi

ios - 当用户触摸警报周围时,如何防止我的 SDCAlertview 关闭?

转载 作者:行者123 更新时间:2023-11-30 12:01:14 25 4
gpt4 key购买 nike

如何将missOnOutsideTapped 设置为 false?我试图阻止用户在点击“确定”按钮之前关闭 AlertController

myView.translatesAutoresizingMaskIntoConstraints = false
myView.heightAnchor.constraint(equalToConstant: 100).isActive = true

let attributedString = NSAttributedString(string: title, attributes: [
NSAttributedStringKey.foregroundColor : #colorLiteral(red: 0.8226075768, green: 0.2890471816, blue: 0.2390623093, alpha: 1)
])
let alert = AlertController(title: "", message: "")
alert.setValue(attributedString, forKey: "attributedTitle")


let OkAction: AlertAction = AlertAction(title: "OK", style: .preferred) { (action) in
MyCode......
}
alert.addAction(OkAction)
alert.contentView.addSubview(myView)
myView.leftAnchor.constraint(equalTo: alert.contentView.leftAnchor).isActive = true
myView.rightAnchor.constraint(equalTo: alert.contentView.rightAnchor).isActive = true
myView.centerXAnchor.constraint(equalTo: alert.contentView.centerXAnchor).isActive = true
myView.topAnchor.constraint(equalTo:alert.contentView.topAnchor, constant: -25).isActive = true
content.bottomAnchor.constraint(equalTo: alert.contentView.bottomAnchor).isActive = true



alert.view.tintColor = #colorLiteral(red: 0.8226075768, green: 0.2890471816, blue: 0.2390623093, alpha: 1)
alert.present()

最佳答案

您可以使用AlertBehaviors来禁用外部触摸。像这样的东西。

let alert = AlertController(title: "", message: "")
alert.behaviors = AlertBehaviors.init(rawValue: 0)

有关详细信息,请参阅 github 中的 AlertBehaviors docs

关于ios - 当用户触摸警报周围时,如何防止我的 SDCAlertview 关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47195592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com