Sélecteur de swift3

Pourquoi n'est-ce pas le travail en swift 3 ? Il se bloque au moment de l'exécution en disant:

'-[my_app_name.displayOtherAppsCtrl appuyez sur:]: unrecognized sélecteur envoyé
pour exemple 0x17eceb70'

    override func viewDidLoad() {
    super.viewDidLoad()

    //Uncomment the following line to preserve selection between presentations
    //self.clearsSelectionOnViewWillAppear = false

    //Register cell classes
    //self.collectionView!.register(ImageCell.self, forCellWithReuseIdentifier: reuseIdentifier)

    //Do any additional setup after loading the view.

  let lpgr = UITapGestureRecognizer(target: self, action: Selector("tap:"))
    lpgr.delegate = self
    collectionView?.addGestureRecognizer(lpgr)
}

func tap(gestureReconizer: UITapGestureRecognizer) {
if gestureReconizer.state != UIGestureRecognizerState.ended {
  return
}

let p = gestureReconizer.location(in: self.collectionView)
let indexPath = self.collectionView?.indexPathForItem(at: p)

if let index = indexPath {
  //var cell = self.collectionView?.cellForItem(at: index)
  //do stuff with your cell, for example print the indexPath
  print(index.row)
} else {
  print("Could not find index path")
}
}
  • Vous avez écrit Selector("tap:"). Vous avez reçu un avertissement. Vous ignoré. Vous s'est écrasé.
InformationsquelleAutor Chris | 2016-06-26