加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – shouldAutorotateToInterfaceOrientation不起作用

发布时间:2020-12-15 01:59:18 所属栏目:百科 来源:网络整理
导读:我一直以肖像模式写我的通用应用程序, 现在大概有15个nib文件,很多viewCotnrollers, 我想实现shouldAutorotateToInterfaceOrientation并在Landscape模式下设计一些屏幕。 添加: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation
我一直以肖像模式写我的通用应用程序,
现在大概有15个nib文件,很多viewCotnrollers,
我想实现shouldAutorotateToInterfaceOrientation并在Landscape模式下设计一些屏幕。

添加:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 return YES;
}

对我所有的看法控制者,不做工作。

在调试期间,我看到这种方法被调用,但它不会工作!不是在模拟器中,不在设备中,不在Iphone中,不在Ipad中!

我在论坛上搜索过一些答案,并看到一些建议使用:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 return (interfaceOrientation == UIInterfaceOrientationPortrait ||
   interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
   interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
   interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown );
}

没有工作,

添加:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];

对我的viewDidLoad和viewDidUnload分别没有工作。

我失去了..任何帮助将做!

只有一个信息…所有我的意见是类型UIControl,因为我需要TuchUpInside工作。

适合你的帮助

解决方法

确保您的所有父视图都具有自动调整Subviews = YES。如果您没有在IB中为所有视图设置弹簧和支柱,则可能需要在代码中执行此操作。

引用Interface Builder用户指南:

Important: In a Cocoa nib file,if you
do not set any springs or struts for
your view in Interface Builder but
then do use the setAutoresizingMask:
method to add autosizing behavior at
runtime,your view may still not
exhibit the correct autoresizing
behavior. The reason is that Interface
Builder disables autosizing of a
parent view’s children altogether if
those children have no springs and
struts set. To enable the autosizing
behavior again,you must pass YES to
the setAutoresizesSubviews: method of
the parent view. Upon doing that,the
child views should autosize correctly.

需要注意的其他几件事情

>如果UINavigationController的根视图控制器也设置为autorotate,那么它只会自动转换。>如果所有的视图控制器都设置为自动转换,UITabBarController将只会自动转换。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读