iOS开发中didSelectRowAtIndexPath tap事件响应延迟
生活随笔
收集整理的這篇文章主要介紹了
iOS开发中didSelectRowAtIndexPath tap事件响应延迟
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
iOS開發(fā)中didSelectRowAtIndexPath tap事件響應延遲
為UITableViewCell添加tapped事件,代碼如下:
class VideoViewController: UIViewController , UITableViewDataSource,UITableViewDelegate { //...func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {// 播放框背景圖片let imageName : String = "cs50-"+String(indexPath.row+1)let image:UIImage = UIImage(named: imageName)!backgroundImageView.image = nilbackgroundImageView.contentMode = UIViewContentMode.ScaleAspectFitbackgroundImageView.clipsToBounds = truebackgroundImageView.image = image} }?我希望點擊列表中某個視頻,再屏幕上方UIImageView中顯示這個視頻的背景圖片。然而運行結(jié)果事與愿違,第一次點按并無響應;第二次點按后UIImageView顯示第一次點按應該顯示的圖片。
仔細檢查后發(fā)現(xiàn),tableView的委托方法中,除了didSelectRowAtIndexPath,還有一個didDeselectRowAtIndexPath,這兩者不仔細看根本看不出來。由于代碼自動補全的時候De排在Se之前,所以我選擇了不合適的方法didDeselect...
?
?
// 感謝這位帖主??主題 : iPhone開發(fā)中的“幽靈”——按兩次,- (void)tableView:didDeselectRowAtIndexPath:才響應??
?
posted on 2016-06-16 22:40 大俠去哪兒 閱讀(...) 評論(...) 編輯 收藏轉(zhuǎn)載于:https://www.cnblogs.com/yinkw/p/5592380.html
總結(jié)
以上是生活随笔為你收集整理的iOS开发中didSelectRowAtIndexPath tap事件响应延迟的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于图片轮播的几种思路
- 下一篇: 数学之旅-不动点定理