Je souhaite placer l'objet à l'endroit où le contact est levé (hors de l'écran).Comment obtenir l'objet UIView à l'emplacement de UITouch à partir de - (void) touchesEnded: withEvent :?
Il sera utilisé pour mettre en œuvre un glisser-déposer et j'ai ces méthodes permettant de passer outre:
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
Utilisation [[touches anyObject] view]
en touchesEnded: withEvent: me donne l'objet UIView de l'endroit où je suis touché, mais pas où j'ai relâché mon contact. L'utilisation de [[touches anyObject] locationInView:self.view]
me donne l'endroit où la touche a été relâchée, mais je devrais mapper les coordonnées à UIView.
Peut être cela vous aidera: [http://stackoverflow.com/questions/16328875/how-to-find-out-what-view-a-touch-event -end-at] (http://stackoverflow.com/questions/16328875/how-to-find-out-what-view-a-touch-event-ended-at) –
@Ronak Chaniyara AH. Je vous remercie. Je ne pouvais pas le trouver n'importe où; Je suppose que je ne faisais que googler les mauvais mots. – David
Super vous l'avez réparé! @David –