ios - UISwipeGesture on imageView within tableView not working -


i'm trying add swipe gesture(left/right) on uiimageview within tableviewcell. have working, however, i'm having trouble when swipe(left/right) image show change.

here's code add swipe gesture within cellforrowatindexpath

resultsimagefileone[indexpath.row].getdatainbackgroundwithblock{ (imageonedata: nsdata?, error: nserror?) -> void in    if error == nil {       let imageone = uiimage(data: imageonedata!)       //cell.imageview.image = imageone <- set image uiimageview        self.pictureone = imageone //global   } }  resultsimagefiletwo[indexpath.row].getdatainbackgroundwithblock { (imagetwodata: nsdata?, error: nserror?) -> void in    if error == nil {       let imagetwo = uiimage(data: imagetwodata!)       //cell.imageview.image = imagetwo <- set image uiimageview        self.picturetwo = imagetwo //global   } }   var swipeleft = uiswipegesturerecognizer(target: self, action: "swipeimage:")  swipeleft.direction = uiswipegesturerecognizerdirection.left   var swiperight = uiswipegesturerecognizer(target: self, action: "swipeimage:")  swiperight.direction = uiswipegesturerecognizerdirection.right   cell.maindrawview.addgesturerecognizer(swipeleft)  cell.maindrawview.addgesturerecognizer(swiperight) 

my selector method: prints out correct direction except can't change image inside cell outside method. when swipe happens crashes saying found nil.

func swipeimage(sender: uiswipegesturerecognizer){  var newcell: tableviewcell = tableviewcell()  if (sender.direction == .left){     println("swiped left")  //change image in tableviewcell newcell.imageview.image = pictureone } if (sender.direction == .right){            println("swiped right")    //change image in tableviewcell    newcell.imageview.image = pictureone   } } 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -