2014-03-03 92 views
0

嗨,我正在努力与自动布局xcode5。也许我完全错了,还有另一种方法来获得我想要的结果。自动布局旋转修复位置

看看:

这是我的纵向视图我如何在接口设计使得它

enter image description here

这是我想按钮留在景观旋转

enter image description here

所以有一种方法可以在界面生成器和自动布局中完成此操作,或者我还有另一条路要走吗?

回答

0

您正在要求按钮从底部一直移动到顶部。这不会自动发生!您需要自己在代码中移动按钮。在视图控制器上执行viewWillLayoutSubviews并将按钮定位在那里。

1

是的,有。

有两种方法:短和“右”。

短道

  1. 在viewDidLoad中添加通知(不要忘记在dealloc的退订)

    //不要忘记第一行,否则你不会GER方向。 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged :) name:UIDeviceOrientationDidChangeNotification object:nil];

  2. 添加约束底间距景观 - 上海华

  3. 这个约束你的代码(如您连接口)连接
  4. 如果orientationChanged方法设置所需的值:

    self.constaint.constant = UIDeviceOrientationIsLandscape ([UIApplication sharedApplication] .statusBarOrientation)? 10:200;

正道

所有的代码与约束处理应该去 - 的UIView(无效)updateConstraints。