底部布局的约束问题

时间:2013-09-25 20:11:01

标签: ios layout constraints

我从底部布局得到一些约束相关的问题。 UITabBarViewController中有一些视图。当我从选项卡切换到另一个视图并返回到第一个视图时,视图控件不会将底部布局识别为选项卡栏,而是从视图的底部识别。

我在此处上传了问题:https://sites.google.com/site/rveducationapps/layoutError.png?attredirects=0&d=1

我已经尝试过放入ViewDidAppear和ViewWillAppear:

[self.view layoutSubviews];
[self.view setNeedsUpdateConstraints];

我在两种情况下记录了子视图,右边一个,在我退出并返回视图后:

subviews:(
"<UIView: 0x146b2260; frame = (210 0; 814 712); autoresize = RM+BM; layer = <CALayer: 0x146b22c0>>",
"<UIButton: 0x146a9eb0; frame = (727 672; 287 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x146aa070>>",
"<UITableView: 0x151d3400; frame = (0 0; 210 761); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x146b14b0>; layer = <CALayer: 0x146ade20>; contentOffset: {0, 0}>",
"<_UILayoutGuide: 0x146b23b0; frame = (0 0; 0 20); hidden = YES; layer = <CALayer: 0x146b24a0>>",
"<_UILayoutGuide: 0x146b28a0; frame = (0 712; 0 56); hidden = YES; layer = <CALayer: 0x146b2910>>"

subviews:(
"<UIView: 0x146b2260; frame = (210 0; 814 768); autoresize = RM+BM; layer = <CALayer: 0x146b22c0>>",
"<UIButton: 0x146a9eb0; frame = (727 728; 287 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x146aa070>>",
"<UITableView: 0x151d3400; frame = (0 0; 210 817); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x146b14b0>; layer = <CALayer: 0x146ade20>; contentOffset: {0, 0}>",
"<_UILayoutGuide: 0x146b23b0; frame = (0 0; 0 20); hidden = YES; layer = <CALayer: 0x146b24a0>>",
"<_UILayoutGuide: 0x146b28a0; frame = (0 768; 0 0); hidden = YES; layer = <CALayer: 0x146b2910>>"

我发现存在一些差异,特别是:"<_UILayoutGuide: 0x146b28a0; frame = (0 712; 0 56); hidden = YES; layer = <CALayer: 0x146b2910>>"

但我不知道如何解决它。

EDITED: 我想我修好了。我在故事板中选择了UIViewController并禁用了EXTEND EDGES-&gt; Under Bottom Bars选项。

1 个答案:

答案 0 :(得分:0)

如果您要从UITabBarViewController转换为新的UIViewController,然后尝试从tabBarController转回UIViewController,那么您可以 segue 返回UITabBarViewController(segue将带您回到UITabBarViewController rootViewController

如果您需要转换回特定标签,请实例化自定义 segue ,然后使用其他指定的VC将其发送回其他标签,可以在UITabBarViewController类或应用AppDelegate.m文件中设置。