xib中针对横竖屏做了两个view,横竖屏切换着使用。添加约束的时候,应该怎么添加?已经试过相对四周均为0了,但是横竖屏一切换,显示就出现一些问题。
高洛峰2017-04-18 09:39:53
Sorry, I checked the code again. It was the view association error in my own code. There is no problem with autoLayout. Attached is my approach:
How to rotate the screen:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
// Executed when the screen changes from portrait to landscape
self.view = _hView;
}else{
// Executed when the screen changes from landscape to portrait
self.view = _vView;
}
}
天蓬老师2017-04-18 09:39:53
Look at the size class.
Different constraints can be set for different size categories