iOS 13 动画视图不改变帧 [英] iOS 13 Animating View Not Changing Frame

查看:19
本文介绍了iOS 13 动画视图不改变帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 iOS 13 模拟器上的 Xcode 10 中编译的应用程序.在一个视图中,有一个托盘"视图,在点击时从底部显示,在 iOS 12 中它可以完美运行,在 iOS 13 中,点击正在调用该方法,但对框架的更改并未保存 - 我已包含输出从调试器的注释中,您可以看到帧值的输出是什么;

I have an app which is compiled in Xcode 10 on iOS 13 simulator. In one view there is a "tray" view which shows from the bottom when tapped, in iOS 12 it works perfectly, in iOS 13, the tap is calling the method, but the changes to the frame are not saving - I have included outputs from the debugger in comments so you can see what the outputs of the frame values are;

- (void) userClickActivityTray: (UITapGestureRecognizer *) gestureRecognizer {
if(self.activityTrayShown) {
    /*
     (lldb) po self.activityTrayContainerView.frame
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))
     */
    [self hideActivityTray];
} else {
    if (!self.activityTrayViewInitialFrameComputed) {
        self.activityTrayViewInitialFrameComputed = YES;
        self.activityTrayInitialFrame = self.activityTrayContainerView.frame;
    }

    /*
     (lldb) po self.activityTrayContainerView.frame
     (origin = (x = 0, y = 638), size = (width = 414, height = 224))
     (origin = (x = 0, y = 638), size = (width = 414, height = 224))

     (lldb) po self.activityTrayInitialFrame
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))

     (lldb)
     */

    [UIView animateWithDuration:0.25 animations:^{
        self.activityTrayContainerView.frame = CGRectMake(self.view.bounds.origin.x,
                                                          self.bottomView.frame.origin.y - self.activityTrayViewController.maximumHeight,
                                                          self.view.bounds.size.width,
                                                          self.activityTrayViewController.maximumHeight);

        self.activityTrayBackgroundView.alpha = 1.0;
        self.bottomView.alpha = self.dotsProgressView.alpha = 0;
    } completion:^(BOOL finished) {
        self.activityTrayShown = YES;
        /*
         (lldb) po self.activityTrayContainerView.frame
         (origin = (x = 0, y = 557), size = (width = 414, height = 305))
         (origin = (x = 0, y = 792), size = (width = 414, height = 104))
         */
    }];
}

}

推荐答案

iOS 13 中的布局系统不同,我们遇到了同样的问题,在我们的例子中,通过从 automatic<切换 layout/code> 到 Translates Mask Into Constraints 解决了这个问题.

Layout system in iOS 13 is different, we had the same issue and in our case by switching layout from automatic to Translates Mask Into Constraints fixed the issue.

这篇关于iOS 13 动画视图不改变帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆