iphone - UIView动画异常

标签 iphone ios core-animation uigesturerecognizer

我目前正在尝试使用滑动手势从一个 View 到另一个 View 的动画,这反过来会将 View A 从屏幕向左动画化,然后让 View B 从右侧出现并随之动画化。

这实际上在我的应用程序中起作用,但是当 View 动画而不是 View B 跟随 View A 的边缘并让它们同时移动时, View B 不会移动,直到 View 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

任何帮助将不胜感激。

最佳答案

修复了您的代码并重新上传了项目 here

我所做的更改:

-(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)];
        }];
    }

关于iphone - UIView动画异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10811286/

相关文章:

ios - imageWithCGImage 的内存问题

objective-c - 使用Core Animation/CALayer进行简单的分层绘画

html - iPhone 上的网站很小

iphone - uitableview 中返回的单元格数

iphone - 如果我使用自定义 UITableViewCell,是否需要设置 heightForRowAtIndexPath?

objective-c - 为什么这种使用 CATransform3D 的转换会减小 View 的宽度?

iOS objective-C : Determine current 3D rotation of a UIView

iphone - 如何在 itunes connect 上离开团队?

ios - UITableView 异步图像加载 - 滚动之前不布局

ios - 如何使用 Firebase Web 将链接中的图像保存到 Firebase 存储?