【发布时间】:2016-08-11 19:24:01
【问题描述】:
我有两个 VC。一个作为导航控制器,另一个作为模式视图。 我正在使用 segue 来显示模态视图。
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.performSegueWithIdentifier("openFilterSegue", sender: nil)
});
然后打开类似的东西
class FilterVC: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource, AlertMessage {
override func viewDidLoad() {
pickerView.dataSource = self
pickerView.delegate = self
}
func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView!) -> UIView {
let pickerLabel = UILabel()
pickerLabel.textColor = UIColor.blackColor()
pickerLabel.text = arrShopCentrum[row].nazev
pickerLabel.font = UIFont(name: "Roboto-Regular", size: 15)
pickerLabel.textAlignment = NSTextAlignment.Center
return pickerLabel
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return arrPlace.count
}
}
当我第一次打开该 VC 时,加载大约需要 3 秒。然后我关闭它,它会打开得更快。
顺便说一句,我在那里使用REALM 对象数据库,但我认为这不是问题。
它在storyboards中和Delegate + datasource是相连的
【问题讨论】:
-
你有没有用仪器来看看什么需要这么长时间?
-
嗨,我想你忘了在 FilterVC 中超级调用 viewDidLoad 方法。
-
我调用了 super.viewdidload。没有任何改善。
-
@EmilioPelaez:我认为 80% 是 Pickerview。没有自动布局冲突或其他问题。
-
Instruments 的结果到底是什么?
标签: ios swift uipickerview