显示模态后移动视图 - 可能与AutoLayout相关 [英] Shifting view after displaying modal - possibly AutoLayout related

查看:76
本文介绍了显示模态后移动视图 - 可能与AutoLayout相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供了一个简单的视图与一些标签和一个按钮,所有内部的 UIScrollView 并使用自动布局布局。

I present a simple view with a couple of labels and a button, all inside a UIScrollView and laid out using auto layout.

演示项目这里是这个问题的一个小例子。在iPhone模拟器中运行它,并滚动到底部使用'模态'按钮。

The demo project here is a small example of this issue. Run it in the iPhone simulator and scroll to the bottom to use the 'modal' button. After dismissing the modal attempt to scroll back to the top - the issue should be clear.

或者参考下面图片中的滚动条来查看问题。

Or refer to the scroll bar in the images below to see the problem.

在演示前

演讲后

推荐答案

我不是专家AutoLayout,但我通过添加标签&按钮约束到 self.view 而不是 self.scrollView

I'm not an expert in AutoLayout, but I fixed it by adding the label & button constraints to self.view instead of self.scrollView.

例如:

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[l1]"
                                                                  options:0
                                                                  metrics:nil
                                                                    views:@{@"l1":self.l1}]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[l1]"
                                                                  options:0
                                                                  metrics:nil
                                                                    views:@{@"l1":self.l1}]];

为什么要修复它...不知道:D

Why this fixes it... have no idea :D

这篇关于显示模态后移动视图 - 可能与AutoLayout相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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