I have a simple UITableViewController with basic cell. didSelectRowAtIndexPath do simple job - just make UIAlertView and show it.
The problem is when I tap on a row sometimes I see alert immediately, sometimes after few seconds (up to 10 seconds).
The code is
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
}
In log I see
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
but actually alert not shows on the screen.
Any suggestions or pointings where to find a solution would be appreciated.
The solution is very weird
replacing
cell.selectionStyle = UITableViewCellSelectionStyle.None
with
cell.selectionStyle = UITableViewCellSelectionStyle.Default
completely solve the problem. After that every click on row will show result immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With