The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Touches ended is causing issues with segue animation
Discuss Touches ended is causing issues with segue animation in the C Programming forum on Dev Shed. Touches ended is causing issues with segue animation C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 30th, 2012, 12:13 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 2
Time spent in forums: 4 m 3 sec
Reputation Power: 0
|
|
|
Touches ended is causing issues with segue animation
Im making a fairly simple app for the iPad using xCode (written in objective c of course).
Im using the below code for touches ended. After a few uiimageviews are moved around a bit I call a segue in my code like this: [self performSegueWithIdentifier: @"segueToLevel2" sender: self]
The segue's transition types are set to "cross dissolve".
With the code below everything works fine until I get to level 5. On level five when the segue is called it does a corner to corner flip instead of the cross dissolve and from this point on every segue in my app does this flip instead of what they were set to do. If I take out my touches ended method everything works as expected so it seems the problem must be here. I just cant figure out why this works for levels 1-4 but craps out on level 5. Any help would be greatly appreciated....im loosing my mind here.
Code:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
switch (level) {
case 1:{
if ((piece11.hidden == YES) && (piece1moving.hidden == NO) && (piece1placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece1moving.frame = CGRectMake(-65, 153, 490, 422);
[UIView commitAnimations];
[NSTimer scheduledTimerWithTimeInterval:3 target:(self) selector:@selector(moveToFront) userInfo:(nil) repeats:NO];
[NSTimer scheduledTimerWithTimeInterval:1 target:(self) selector:@selector(singlePieceCallback) userInfo:(nil) repeats:NO];
}
}
break;
case 2:{
UITouch *touch1 = [[event allTouches] anyObject];
if (([touch1 view] == piece1) && (piece1placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece1.frame = CGRectMake(47, 402, 305, 312);
[UIView commitAnimations];
}
if (([touch1 view] == piece2) && (piece2placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece2.frame = CGRectMake(34, 4, 291, 399);
[UIView commitAnimations];
}
}
break;
case 3:{
UITouch *touch1 = [[event allTouches] anyObject];
if (([touch1 view] == piece1) && (piece1placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece1.frame = CGRectMake(1, 419, 308, 356);
[UIView commitAnimations];
}
if (([touch1 view] == piece2) && (piece2placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece2.frame = CGRectMake(-7, 67, 291, 315);
[UIView commitAnimations];
}
if (([touch1 view] == piece3) && (piece3placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece3.frame = CGRectMake(-16, 169, 427, 310);
[UIView commitAnimations];
}
}
break;
case 4:{
UITouch *touch1 = [[event allTouches] anyObject];
if (([touch1 view] == piece1) && (piece1placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece1.frame = CGRectMake(0, 76, 219, 261);
[UIView commitAnimations];
}
if (([touch1 view] == piece2) && (piece2placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece2.frame = CGRectMake(89, 485, 255, 287);
[UIView commitAnimations];
}
if (([touch1 view] == piece3) && (piece3placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece3.frame = CGRectMake(103, 197, 305, 330);
[UIView commitAnimations];
}
if (([touch1 view] == piece4) && (piece4placedstate == 0)){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece4.frame = CGRectMake(5, 277, 228, 294);
}
}
break;
case 5:{
UITouch *touch1 = [[event allTouches] anyObject];
if (([touch1 view] == piece1) && (piece1placedstate == 0)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece1.frame = CGRectMake(115, 89, 247, 263);
[UIView commitAnimations];
}
if (([touch1 view] == piece2) && (piece2placedstate == 0)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece2.frame = CGRectMake(14, 497, 211, 271);
[UIView commitAnimations];
}
if (([touch1 view] == piece3) && (piece3placedstate == 0)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece3.frame = CGRectMake(92, 248, 244, 272);
[UIView commitAnimations];
}
if (([touch1 view] == piece4) && (piece4placedstate == 0)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece4.frame = CGRectMake(87, 458, 228, 294);
}
if (([touch1 view] == piece5) && (piece5placedstate == 0)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece5.frame = CGRectMake(-13, 102, 244, 303);
}
}
break;
default:
break;
}
|

October 2nd, 2012, 06:13 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 2
Time spent in forums: 4 m 3 sec
Reputation Power: 0
|
|
I'm still not sure what was causing my issue with the above code but I have found a solution in re-writing my code and using a UIPanGestureRecognizer like the one below attached to each of the pieces. This works perfectly throughout.
Code:
- (void) dragGesture5:(UIPanGestureRecognizer *) panGesture {
CGPoint translation = [panGesture translationInView:self.view];
switch (panGesture.state) {
case UIGestureRecognizerStateBegan:{
originalCenter = piece5.center;
[self.view bringSubviewToFront:piece5];
}
break;
case UIGestureRecognizerStateChanged:{
piece5.center = CGPointMake(piece5.center.x + translation.x,
piece5.center.y + translation.y);
[self checkColision];
}
break;
case UIGestureRecognizerStateEnded:{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
piece5.center = originalCenter;
[UIView commitAnimations];
}
break;
default:
break;
}
[panGesture setTranslation:CGPointZero inView:self.view];
}
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|