但是我对buttones有疑问,
这是一张照片
当我试图改变约束时,按钮保持不动
我在这里读了很多答案,但我没有找到任何solotuin
这是我的代码:
func distance(){ let ediTradiusAlert = UIAlertController(Title: "Choose distance",message: "",preferredStyle: UIAlertControllerStyle.alert) let pickeVIEwFrame: CGRect = CGRect(x: 0,y: 0,wIDth: 250,height: 300) let pickerVIEwRadius: UIPickerVIEw = UIPickerVIEw(frame: pickeVIEwFrame) pickerVIEwRadius.delegate = self pickerVIEwRadius.dataSource = self ediTradiusAlert.vIEw.addSubvIEw(pickerVIEwRadius) ediTradiusAlert.addAction(UIAlertAction(Title: "Done",style: UIAlertActionStyle.default,handler:nil)) ediTradiusAlert.addAction(UIAlertAction(Title: "Cancel",style: UIAlertActionStyle.cancel,handler: nil)) ediTradiusAlert.vIEw.addConstraint(NSLayoutConstraint(item: ediTradiusAlert.vIEw,attribute: NSLayoutAttribute.height,relatedBy: NSLayoutRelation.equal,toItem: nil,attribute: NSLayoutAttribute.notAnAttribute,multiplIEr: 1,constant: self.vIEw.frame.height * 0.5)) self.present(ediTradiusAlert,animated: true,completion: nil)}而不是添加pickerVIEw作为子视图尝试设置UIAlertController的contentVIEwController像这样.
let vc = UIVIEwController()vc.preferredContentSize = CGSize(wIDth: 250,height: 300)let pickerVIEw = UIPickerVIEw(frame: CGRect(x: 0,height: 300))pickerVIEw.delegate = selfpickerVIEw.dataSource = selfvc.vIEw.addSubvIEw(pickerVIEw)let ediTradiusAlert = UIAlertController(Title: "Choose distance",preferredStyle: UIAlertControllerStyle.alert)ediTradiusAlert.setValue(vc,forKey: "contentVIEwController")ediTradiusAlert.addAction(UIAlertAction(Title: "Done",style: .default,handler: nil))ediTradiusAlert.addAction(UIAlertAction(Title: "Cancel",style: .cancel,handler: nil))self.present(ediTradiusAlert,animated: true)
它看起来像下面.
总结以上是内存溢出为你收集整理的swift UIAlertController与pickerView按钮 *** 作熬夜全部内容,希望文章能够帮你解决swift UIAlertController与pickerView按钮 *** 作熬夜所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)