ios - Image snaps back when using BringSubviewToFront -
i'm making first app solitaire game - user has move cards around , stack them onto each other. i'm new objective-c hope forgive me when question stupid.
so i'm trying things out , have 2 uiimageviews uipangesturerecgonizer attached them. whenever user drags 1 of cards must on top of other card. i'm using code below in viewcontroller.m file problem when drag 1 card , want drag other card, first card snaps original position, stay dragged it. when comment out bringsubviewtofront not happen, 1 of cards stays behind other.
-(ibaction)dragcard:(uipangesturerecognizer *)recognizer { uiview *cardview = [(uipangesturerecognizer *)recognizer view]; [self.view bringsubviewtofront:cardview]; cgpoint translation = [recognizer translationinview:self.view]; recognizer.view.center = cgpointmake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y); [recognizer settranslation:cgpointzero inview:self.view];} i cannot figure out what's causing this. can please me...
edit: logged self.view.subviews show what's happening. have dragged image tag 1 , start dragging image tag 2. can see both coordinates change - image tag 1 moves original position , image tag 2 moves:
2013-05-16 17:02:20.424 ( "<uiimageview: 0x71749e0; frame = (0 0; 320 411); autoresize = tm+bm; userinteractionenabled = no; layer = <calayer: 0x7174a40>>", "<uiimageview: 0x7172ef0; frame = (25 77; 42 58); autoresize = tm+bm; tag = 1; gesturerecognizers = <nsarray: 0x7171700>; layer = <calayer: 0x7171620>>", "<uiimageview: 0x71722f0; frame = (88 200; 42 58); autoresize = tm+bm; tag = 2; gesturerecognizers = <nsarray: 0x7171bc0>; layer = <calayer: 0x7172350>>" 2013-05-16 17:02:20.441 ( "<uiimageview: 0x71749e0; frame = (0 0; 320 411); autoresize = tm+bm; userinteractionenabled = no; layer = <calayer: 0x7174a40>>", "<uiimageview: 0x7172ef0; frame = (30 177; 42 58); autoresize = tm+bm; tag = 1; gesturerecognizers = <nsarray: 0x7171700>; layer = <calayer: 0x7171620>>", "<uiimageview: 0x71722f0; frame = (91 201; 42 58); autoresize = tm+bm; tag = 2; gesturerecognizers = <nsarray: 0x7171bc0>; layer = <calayer: 0x7172350>>" the first imageview background image.
alright, found answer here. issue bringsubviewtofront , autolayout. sorry repeating question.
Comments
Post a Comment