显示模式后移观点 - 可能自动版式相关 [英] Shifting view after displaying modal - possibly AutoLayout related

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

问题描述

我present一个简单的观点与一对夫妇的标签和一个按钮,所有在的UIScrollView 和使用自动排版布局。

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

按钮presents另一种看法,其中包括解雇的导航项目。

The button presents another view, which includes a navigation item for dismissal.

辞退后,虽然原来的内容的UIScrollView 偏移。奇怪的是,通过其偏移量为presentation的时间似乎与滚动位置。

After dismissal, though, the content of the original UIScrollView is offset. Strangely, the amount by which it is offset seems related to the scroll position at the time of presentation.

示范项目 是这个问题的一个小例子。在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.

在preSENTATION

BEFORE PRESENTATION

在preSENTATION

AFTER PRESENTATION

推荐答案

我不是一个自动版式专家,但我通过添加标签和放大器固定它;键约束 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

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

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