这段代码出错了,添加alertVC.setValue(alertView, forKey: "FullintentViewController")的时候就会出现terminating with uncaught exception of type NSException的错误,是怎么回事呢
swift alertcontroller添加view出错
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
oyljerry 2016-05-27 06:37关注直接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:{})本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报