0

我目前正在尝试使用滑动手势从一个视图动画到另一个视图,这反过来将动画视图 A 从屏幕上移到左侧,然后让视图 B 从右侧出现动画。

这实际上在我的应用程序中有效,但是当视图动画而不是视图 B 跟随视图 A 的边缘并让它们同时移动时,视图 B 将不会移动,直到视图 A 的动画完成...

这就是代码的样子

- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture
{
    if (gesture.direction = UISwipeGestureRecognizerDirectionLeft) {
        [UIView animateWithDuration:1.50 animations:^{

//            [self.detailViewB.view setAlpha:1.0f];
            [self.detailViewB.view setCenter:CGPointMake(CGRectGetMidX(self.view.frame), CGRectGetMidY(self.view.frame))];
            [self.detailViewA.view setCenter:CGPointMake(-640, CGRectGetMidY(self.view.frame))]; 
        }];
    }
}

如果你想自己编译源代码,这里是我正在搞乱的代码的链接。 http://dl.dropbox.com/u/53813770/SMPrototypeB.zip

任何帮助将不胜感激。

4

1 回答 1

1

修复了您的代码并在此处重新上传了项目

我所做的更改:

-(void) viewDidLoad
{
    [self.detailViewB.view setFrame:CGRectMake(320, 0, self.view.frame.size.width, self.view.frame.size.height)];

}


- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture
{
    if (gesture.direction = UISwipeGestureRecognizerDirectionLeft) {
        [UIView animateWithDuration:1.50 animations:^{

            //            [self.detailViewB.view setAlpha:1.0f];
            [self.detailViewB.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
            [self.detailViewA.view setFrame:CGRectMake(-320, 0, self.view.frame.size.width, self.view.frame.size.height)];
        }];
    }
于 2012-05-30T06:59:07.637 回答