Xin chào các sự kiện cảm ứng, ứng dụng của tôi không xem hoạt ảnh. Nếu người dùng thực sự nhanh chóng và thực hiện một liên lạc khác ngay cả khi hoạt ảnh hiện tại đang diễn ra thì mọi thứ sẽ bị rối tung lên.Đồng bộ hóa hoạt ảnh UIView
Có cách nào tiêu chuẩn để xử lý vấn đề này do khung công tác cung cấp không? Hay tôi đang làm hoạt hình theo cách sai?
Hiện tại, bạn đang kiểm tra cờ (animationInProgress) để xử lý điều này nhưng tôi muốn biết liệu đó có phải là điều chúng tôi phải giải quyết cho điều này không?
Đây là mã:
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
NSMutableArray *c = (NSMutableArray*)context;
UINavigationController *nc = [c objectAtIndex:0];
[nc.view removeFromSuperview];
animationInProgress = NO;
}
- (void)transitionViews:(BOOL)topToBottom {
if (animationInProgress) {
return;
}
animationInProgress = YES;
NSMutableArray *context = [[NSMutableArray alloc] init];
[UIView beginAnimations:@"myanim" context:context];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
UIViewController *from;
UIViewController *to;
if (navController3.view.superview == nil) {
from = navController2;
to = navController3;
} else {
from = navController3;
to = navController2;
}
int height;
if (topToBottom) {
height = -1 * from.view.bounds.size.height;
} else {
height = from.view.bounds.size.height;
}
CGAffineTransform transform = from.view.transform;
[UIView setAnimationsEnabled:NO];
to.view.bounds = from.view.layer.bounds;
to.view.transform = CGAffineTransformTranslate(transform, 0, height);
[window addSubview:to.view];
[UIView setAnimationsEnabled:YES];
from.view.transform = CGAffineTransformTranslate(from.view.transform, 0, -1 * height);
to.view.transform = transform;
[context addObject:from];
[UIView commitAnimations];
return;
}
Nếu bạn dừng bất kỳ sự kiện chạm nào khi nhập ứng dụng của mình trong khi sử dụng hoạt ảnh bằng cách bắt đầu/kết thúcIgnoringInteractionEvents, điều gì sẽ xảy ra với các sự kiện chạm có thể đến khi đang ở trong khối này? Họ sẽ được lưu trữ và trình bày cho các ứng dụng một lần endIgnoringInteractionEvents được gọi là hoặc không ném đi tất cả các chạm (như tên cho thấy)? – vance
@vance: Chúng sẽ bị vứt bỏ, như tên cho thấy. –