To add the tapped event for UITableViewCell, the code is as follows:
Class Videoviewcontroller:uiviewcontroller, Uitableviewdatasource,uitableviewdelegate {//... Func TableView (Tableview:uitableview, didDeselectrowatindexpath indexpath:nsindexpath) { //play box background picture Let imagename:string = "cs50-" +string (indexpath.row+1) let image:uiimage = UIImage (named:imagename)! Backgroundimageview.image = Nil Backgroundimageview.contentmode = Uiviewcontentmode.scaleaspectfit Backgroundbackimageview.clipstobounds = true backgroundbackimageview.image = Image }}
I want to click on a video in the list and then display the background image of the video in the Uiimageview above the screen. However, the result of the operation backfired, the first tap did not respond; the second tap after Uiimageview displays the picture that should appear the first time you click it.
A careful examination revealed that, in addition to the didSelectRowatindexpath, the TableView delegate method had a diddeselectRowatindexpath, The two do not look closely at all. Since the code auto-complete the de line before SE, so I chose the inappropriate method Diddeselect ...
Thank you for this theme: "Ghosts" in iphone development--press two times,-(void) Tableview:diddeselectrowatindexpath: only response
Didselectrowatindexpath Tap Event Response latency in iOS development