swift alertcontroller添加view出错

这段代码出错了,添加alertVC.setValue(alertView, forKey: "FullintentViewController")的时候就会出现terminating with uncaught exception of type NSException的错误,是怎么回事呢
图片说明

0

2个回答

直接addSubview

 var alertController = UIAlertController(title: "\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

let margin:CGFloat = 8.0
let rect = CGRectMake(margin, margin, alertController.view.bounds.size.width - margin * 4.0, 100.0)
var customView = UIView(frame: rect)

customView.backgroundColor = UIColor.greenColor()
alertController.view.addSubview(customView)

let somethingAction = UIAlertAction(title: "Something", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) in println("something")})

let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: {(alert: UIAlertAction!) in println("cancel")})

alertController.addAction(somethingAction)
alertController.addAction(cancelAction)

self.presentViewController(alertController, animated: true, completion:{})
1
llx2007
凌云志轩 网太卡没看见后面代码,谢谢
大约 3 年之前 回复
llx2007
凌云志轩 uialertcontroller没有addSubview
大约 3 年之前 回复
0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!