我有一个叫UIViewController的MainViewController。它的框架:我还有一个名为UIView的SingleSearchView,它是MainViewController的一个子视图。
我将这个singleSearchView添加到MainViewController中:
self.singleSearchView = [[SearchView alloc] initWithFrame:CGRectMake(0, -480, 320, 480)];
[self.view addSubview:singleSearchView];当我尝试下面的动画“切换”到singleSearchView singleSearchView时,它阻止了我与singleSearchView的任何触摸交互
[UIView beginAnimations:@"searchAnimation" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.singleSearchView cache:YES];
[self.view setFrame:CGRectMake(0, 480, 320, 480)];
[UIView commitAnimations];我也尝试过这样做:
[UIView animateWithDuration:1.5 delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
[self.view setFrame:CGRectMake(0, 480, 320, 480)];
}
completion:nil];谢谢
发布于 2011-08-03 13:43:13
弄明白了!
CATransition* trans = [CATransition animation];
[trans setType:kCATransitionPush];
[trans setDuration:0.5];
[trans setSubtype:kCATransitionFromBottom];
[self.singleSearchView setFrame:CGRectMake(0, 0, 320, 480)];
CALayer *layer = self.view.layer;
[layer addAnimation:trans forKey:@"Transition"];发布于 2011-08-03 12:49:00
在默认情况下显示UIView的块动画阻止用户交互,为了绕过它,您需要将UIViewAnimationOptionAllowUserInteraction作为选项之一传递。希望其他人也能利用这些信息。
发布于 2011-08-03 12:54:44
你不应该试图移动self.view。self.view属性在UIVIewControll层次结构中是特殊的。你应该创建一个子视图并动画这个.
https://stackoverflow.com/questions/6926626
复制相似问题