【发布时间】:2015-11-24 22:18:12
【问题描述】:
我想创建一个 UIAlertController 的子类,但我快疯了,因为我的构造函数有问题,这是我的子类:
class loginAlert : UIAlertController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
我认为这个子类必须有构造函数: UIAlertController(title: String, message: String, preferredStyle: UIAlertControllerStyle) ,因为它是 UIAlertController 的子类,但是当我这样做时
loginAlert(title: "test", message: "test", preferredStyle: .Alert)
我得到错误,为什么我错在哪里?
【问题讨论】:
-
错误是什么?为什么要继承 UIAlertController ?
-
因为我想创建一个在我的代码中经常使用的标准 uialertController
-
事实上,如果您愿意,您可以继承
UIAlertController并自定义它的一些私有属性。请注意,Apple 在提交到商店时会检查私有财产和 API 使用情况:iphonedevwiki.net/index.php/UIAlertController -
对不起,你说苹果检查私有财产是什么意思?
标签: ios swift uialertcontroller