gpt4 book ai didi

ios - Swift - 由于 'textFields' 保护级别,无法访问 'fileprivate'

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

我添加了一个对我的警报进行个性化设置的 Pod (PCLBlurEffectAlert)编辑警报、警报操作和警报文本字段后,出现此错误,并且无法使用文本字段。我能做什么?

enter image description here

let alert1 = PCLBlurEffectAlertController(title: NSLocalizedString("AGGENTRATA", comment: ""),
message: NSLocalizedString("insENTRATA", comment: ""),
effect: UIBlurEffect(style: .dark),
style: .alert)
alert1.addTextField( with: { (textField: UITextField!) in
textField.placeholder = NSLocalizedString("ENTRATA_LOCAL", comment: "") //impostiamo il segnaposto del field
textField.isSecureTextEntry = false //se fosse un campo Password mettremmo true
textField.keyboardType = UIKeyboardType.numberPad
} )

alert1.addAction(PCLBlurEffectAlertAction(title: NSLocalizedString("ANNULLA_LOCAL", comment: ""), style: .cancel, handler: { (action) in
UIView.animate(withDuration: 0.4, animations: {
self.blurVisual.effect = nil
})
}))
alert1.addAction(PCLBlurEffectAlertAction(title: NSLocalizedString("AGG", comment: ""), style: .default, handler: { (action) in
UIView.animate(withDuration: 0.4, animations: {
self.blurVisual.effect = nil
})
let textField = alert1.textFields![0] as UITextField

最佳答案

textfieldsPCLBlurEffectAlertController 中的私有(private)变量。所以我们无法访问私有(private)变量。

fileprivate var textFields: [UITextField] = []

你可以这样使用:

var textfield1: UITextField?

let alert1 = PCLBlurEffectAlertController(title: NSLocalizedString("AGGENTRATA", comment: ""),
message: NSLocalizedString("insENTRATA", comment: ""),
effect: UIBlurEffect(style: .dark),
style: .alert)
alert1.addTextField( with: { (textField: UITextField!) in
textField.placeholder = NSLocalizedString("ENTRATA_LOCAL", comment: "") //impostiamo il segnaposto del field
textField.isSecureTextEntry = false //se fosse un campo Password mettremmo true
textField.keyboardType = UIKeyboardType.numberPad
self.textfield1 = textField
} )

alert1.addAction(PCLBlurEffectAlertAction(title: NSLocalizedString("AGG", comment: ""), style: .default, handler: { (action) in
let textField = (self.textfield1?.text as! NSString).floatValue
}))

关于ios - Swift - 由于 'textFields' 保护级别,无法访问 'fileprivate',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46478224/

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