Max*_*Max 14 uitableview uikit ios swift
我有一个简单的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
}
Run Code Online (Sandbox Code Playgroud)
在日志我看到
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
Run Code Online (Sandbox Code Playgroud)
但实际上警告屏幕上没有显示.
任何建议或指向哪里找到解决方案将不胜感激.
Max*_*Max 25
解决方案非常奇怪
更换
cell.selectionStyle = UITableViewCellSelectionStyle.None
Run Code Online (Sandbox Code Playgroud)
同
cell.selectionStyle = UITableViewCellSelectionStyle.Default
Run Code Online (Sandbox Code Playgroud)
彻底解决问题.之后,每次点击行都会立即显示结果.
| 归档时间: |
|
| 查看次数: |
4755 次 |
| 最近记录: |