objective-c – UIView在风景中有纵向尺寸?

objective-c – UIView在风景中有纵向尺寸?,第1张

概述我有一个带有1个UIViewController的故事板,持有1个UIView,其中包含许多嵌套的UIViews.我将View Controller子类化为实现此方法: - (BOOL)shouldAutorotateToInterfaceOrientation: UIInterfaceOrientation)interfaceOrientation { return (interface 我有一个带有1个UIVIEwController的故事板,持有1个UIVIEw,其中包含许多嵌套的UIVIEws.我将VIEw Controller子类化为实现此方法:

- (BOol)shouldautorotatetoInterfaceOrIEntation: UIInterfaceOrIEntation)interfaceOrIEntation {    return (interfaceOrIEntation == UIInterfaceOrIEntationLandscapeRight || interfaceOrIEntation == UIInterfaceOrIEntationLandscapeleft);}

我还补充道

<key>UISupportedInterfaceOrIEntations</key>    <array>     <string>UIInterfaceOrIEntationLandscapeleft</string>     <string>UIInterfaceOrIEntationLandscapeRight</string>    </array><key>UIInterfaceOrIEntation</key><string>UIInterfaceOrIEntationLandscapeleft</string>

到Info.pList.

在主UIVIEw的vIEwDIDLoad中我这样做:

PASectionVIEw* sectionVIEw = [[PASectionVIEw alloc] initWithFrame:CGRectMake(0,self.frame.size.wIDth,180)];[self addSubvIEw:sectionVIEw];

问题是控制只有756像素宽而不是预期的1024.有关详细信息,请参阅下面的屏幕截图.我一直在网上搜索,但我无法找到解决这个令人沮丧的问题的方法.我正在使用Xcode 4.5和iOS5.1设置为基本SDK.

编辑
它通过用边界替换框架来工作.但是我不明白发生了什么,所以它不适用于帧大小.

解决方法

The frame rectangle,which describes the vIEw’s location and size in
its supervIEw’s coordinate system.

@property(nonatomic) CGRect frame

The bounds rectangle,which describes the vIEw’s location and size in
its own coordinate system.

@property(nonatomic) CGRect bounds

使用边界,而不是框架.

总结

以上是内存溢出为你收集整理的objective-c – UIView在风景中有纵向尺寸?全部内容,希望文章能够帮你解决objective-c – UIView在风景中有纵向尺寸?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1015312.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存