ios - CollectionViewCell doesnt work properly with Pinch Gesture -


im using collectionview , pinch gesture connected cvcell. have image in cell , pinch gesture zoom in , out in image. problem pinch gesture works rows, not works odd rows. mean first cell cant zoom picture, can zoom in picture in second cell, , cant 3rd cell , can 4th cell, , goes on this. couldnt find logical explanation. maybe can see miss. in advice. code here:

`

@ibaction func handlepinch(recognizer : uipinchgesturerecognizer) {     if let view = recognizer.view {         view.transform = cgaffinetransformscale(view.transform,             recognizer.scale, recognizer.scale)         recognizer.scale = 1     } }  @iboutlet weak var collectionview: uicollectionview! override func viewdidload() {     super.viewdidload()     var b = uibarbuttonitem(barbuttonsystemitem: .bookmarks, target: self, action: "barbutton")     self.navigationitem.rightbarbuttonitem = b     var itemindex = nsindexpath(foritem: catchnumber, insection: 0)     self.collectionview?.scrolltoitematindexpath(itemindex, atscrollposition: uicollectionviewscrollposition.centeredhorizontally, animated: false) }  override func didreceivememorywarning() {     super.didreceivememorywarning()  }  func barbutton(){     let alert = uialertcontroller(title: "select option", message: " ", preferredstyle: uialertcontrollerstyle.actionsheet)     let sharebutton = uialertaction(title: "share", style: uialertactionstyle.default) { (alert) -> void in         let content = fbsdksharephotocontent()         let photo : fbsdksharephoto = fbsdksharephoto()         photo.image = self.image         photo.usergenerated = true         content.photos = [photo]         fbsdkmessagedialog.showwithcontent(content, delegate:nil)     }     let savebutton = uialertaction(title: "save", style: uialertactionstyle.default) { (alert) -> void in         uiimagewritetosavedphotosalbum(self.image, nil, nil, nil)     }     let deletebutton = uialertaction(title: "delete", style: uialertactionstyle.default) { (alert) -> void in         var tmp = self.catchpictures[self.catchnumber].componentsseparatedbystring("_")         self.iddelete = tmp[1]         let graphrequest : fbsdkgraphrequest = fbsdkgraphrequest(graphpath: "/\(self.iddelete)", parameters: nil , httpmethod: "delete")         graphrequest.startwithcompletionhandler({ (connection, result, error) -> void in             if (error == nil){                 self.navigationcontroller?.popviewcontrolleranimated(true)             }else{                 let alertcontroller = uialertcontroller(title: "delete error", message:                     "an error occured while deleting photo", preferredstyle: uialertcontrollerstyle.alert)                 alertcontroller.addaction(uialertaction(title: "ok", style: uialertactionstyle.default,handler: nil))                  self.presentviewcontroller(alertcontroller, animated: true, completion: nil)             }          })     }     let cancelbutton = uialertaction(title: "cancel", style: uialertactionstyle.cancel) { (alert) -> void in         println("cancel pressed")     }     alert.addaction(sharebutton)     alert.addaction(savebutton)     alert.addaction(deletebutton)     alert.addaction(cancelbutton)     self.presentviewcontroller(alert, animated: true, completion: nil) }  func collectionview(collectionview: uicollectionview, numberofsectionincollectionview section: int) -> int {     return 1 }  func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int {     return catchpictures.count  }  func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {     var cell = collectionview.dequeuereusablecellwithreuseidentifier("photocell", forindexpath: indexpath) as! uicollectionviewcell     let a:uiimageview = cell.contentview.viewwithtag(1) as! uiimageview     dispatch_async(dispatch_get_main_queue(),{         var urlstring: nsstring = self.catchpictures[indexpath.row] nsstring         var imgurl: nsurl = nsurl(string: urlstring string)!         var request: nsurlrequest = nsurlrequest(url: imgurl)         var urlconnection: nsurlconnection = nsurlconnection(request: request, delegate: self)!         nsurlconnection.sendasynchronousrequest(request, queue: nsoperationqueue.mainqueue(), completionhandler: {(response: nsurlresponse!,data: nsdata!,error: nserror!) -> void in             if !(error != nil) {                 var image = uiimage(data: data)                 a.image = image                 self.image = a.image             }})          self.flowlayout.minimuminteritemspacing = 0.0         self.flowlayout.minimumlinespacing = 0.0         self.flowlayout.itemsize = cgsizemake(self.view.frame.width, 350)         self.flowlayout.scrolldirection = uicollectionviewscrolldirection.horizontal         self.collectionview.setcollectionviewlayout(self.flowlayout, animated: true)     })     self.catchnumber = indexpath.row     return cell } 

} `

no no there's no custom cvcell, mistake wrote cvcell short meaning of collectionviewcell seen in code didnt use custom collection view cell ;) sorry misunderstanding


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -