xcode - iOS开发xib中横竖屏两种不同布局,使用autoLayout添加的约束无法正常使用?
伊谢尔伦
伊谢尔伦 2017-04-18 09:37:53
0
2
2065

xib中针对横竖屏做了两个view,横竖屏切换着使用。添加约束的时候,应该怎么添加?已经试过相对四周均为0了,但是横竖屏一切换,显示就出现一些问题。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

Antworte allen(2)
小葫芦

不好意思,又查了一遍代码,是我自己代码中视图关联出错了,autoLayout没有问题。附上我的作法:

旋转屏幕的时候走的方法:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {

// 屏幕从竖屏变为横屏时执行

    self.view = _hView;
}else{

// 屏幕从横屏变为竖屏时执行

    self.view = _vView;
}

}

Peter_Zhu

看下size class吧。
可以针对不同的尺寸分类设置不同的约束

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!