我是新的 iPhone 开发人员,我在 iPad 横向模式下遇到 uiview 动画问题。我有两个 View view1(如分割 View )和 view2(覆盖剩余窗口)。当我触摸从右向左移动 view2 时,它将被覆盖view1 带有移动动画。同时,当我触摸从左向右移动时,view2 会回到原来的位置。请分享您的想法
谨致问候, 拉杰什。
最佳答案
大家好,我终于找到答案了,
- (void)viewDidLoad
{
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[recognizer setNumberOfTouchesRequired:1];
[secondView addGestureRecognizer:recognizer];
[recognizer release];
UISwipeGestureRecognizer *recognizerleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
[recognizerleft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[recognizerleft setNumberOfTouchesRequired:1];
[secondView addGestureRecognizer:recognizerleft];
[recognizerleft release];
[self.view addSubview:secondView];
[super viewDidLoad];
}
//To set the frame position of the view
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
NSLog(@"rightSwipeHandle");
[UIView beginAnimations:@"viewanimations" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
secondView.frame=CGRectMake(360, 0, 660, 768);
[UIView commitAnimations];
}
//To set the frame position of the view
- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
NSLog(@"leftSwipeHandle");
[UIView beginAnimations:@"viewanimations" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
secondView.frame=CGRectMake(200, 0, 858, 768);
[UIView commitAnimations];
}
关于ios - UIview 动画将一个 View 覆盖到另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11561687/