0
我使用下面的代碼進行觸摸結束。經過幾次uiviews圍繞有點感動我叫賽格瑞在我的代碼是這樣的: [自performSegueWithIdentifier:@「segueToLevel2」發件人:自我]觸摸結束導致segue動畫的問題
的賽格瑞的過渡類型均設置爲「跨解散」。
下面的代碼一切正常,直到我到達第5級。在第5級時,當調用segue時,它做了一個角落翻轉而不是交叉溶解,並且從我的應用程序的每個segue的這一點開始而不是他們要做的事情。如果我拿出我的觸摸結束方法,一切都按預期工作,所以問題一定在這裏。我只是無法弄清楚爲什麼這適用於1-4級,但是可以在第5級出現。任何幫助都將不勝感激....即時放鬆我的思緒。
-(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;
}
上面的代碼是不是有什麼問題,或者我被忽略了,因爲我不知道我在做什麼。不要試圖討厭,我只需要知道我是否應該在我的代碼中尋找其他地方......但我不能想到問題的其他地方。 – DelightedD0D