我收到了以下示例的包装错误。不确定如何安全地包装这个,有什么建议吗?
let frame = CGRectMake(10, 20, 300, 150)
let pickerView = AKPickerView(frame : frame)
//breaks here
self.pickerView.delegate = self
self.pickerView.dataSource = self
答案 0 :(得分:0)
试试这个:
let frame = CGRectMake(10, 20, 300, 150)
if let pickerView = AKPickerView(frame : frame)
{
self.pickerView.delegate = self
self.pickerView.dataSource = self
}
答案 1 :(得分:0)
试试这个,在我的代码中进行测试
let frame = CGRectMake(10, 20, 300, 150)
let pickerView = AKPickerView(frame : frame)
pickerView.delegate = self
pickerView.dataSource = self
pickerView.reloadData()
self.view.addSubview(pickerView)
我使用了带有桥接头的Objective-c AKPickerView。