У меня есть простой UITableViewController с базовой ячейкой. didSelectRowAtIndexPath выполняет простую работу - просто сделайте UIAlertView и покажите его.
Проблема в том, что когда я нажимаю на строку, иногда я вижу предупреждение немедленно, иногда через несколько секунд (до 10 секунд).
Код
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
cell.selectionStyle = UITableViewCellSelectionStyle.None
// Configure the cell...
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
NSLog("row clicked at index \(indexPath.row)")
let alert = UIAlertView(title: "Test", message: "Test message", delegate: self, cancelButtonTitle: "Done")
alert.show()
NSLog("alert showed")
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
}
В журнале я вижу
2015-08-06 20:51:54.591 experimental[10323:8602172] row clicked at index 2
2015-08-06 20:51:54.595 experimental[10323:8602172] alert showed
2015-08-06 20:52:00.901 experimental[10323:8602172] row clicked at index 3
2015-08-06 20:52:00.905 experimental[10323:8602172] alert showed
но на самом деле предупреждение не отображается на экране.
Любые предложения или указания, где найти решение, будут оценены.