自动旋转标签栏应用程序
嘿伙计们, 我正在尝试自动旋转我的选项卡栏应用程序。显然,我知道大多数人会说这个问题是 return YES;
或者所有选项卡栏项目必须位于同一类中才能自动旋转。不,这对我不起作用。首先,我有 4 个选项卡栏项目,每个项目都有自己的类。我的前 2 个选项卡栏项目有 UIWebViews,第二个是表视图,最后一个是带有按钮的图像视图。现在,我练习为我的第一个选项卡栏项目实现自动旋转代码,这是一个使用此代码的 UIWebView,因为 return YES;
对我不起作用:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
if (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else
return NO;
}
在没有选项卡栏的情况下使用此代码对我有用,但是当将其与选项卡栏应用程序一起使用时,它对我不起作用。另外,当程序员对我说所有其他选项卡栏应用程序必须具有相同的类文件时,我不能这样做,因为我的每个选项卡栏都有自己的类文件,正如我之前所说的。
所以希望有人可以帮助我解决这种情况,以便自动旋转整个标签栏,谢谢
Hey guys,
I am trying to auto rotate my Tab Bar application. Apparently, I know most people will say to this problem is return YES;
or that all the Tab Bar Items have to be in the same class in order to auto rotate. No. It didn't work for me. So first of all, I have 4 Tab Bar Items, each with it's own Classes. My first 2 Tab Bar Items have UIWebViews, second is a Table View and last is an Image View with buttons. Now I practiced implementing the auto rotate code for my first Tab Bar Item, which is a UIWebView using this code since return YES;
didn't work for me:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
if (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else
return NO;
}
Using this code without a Tab Bar worked for me, but when using this with a Tab Bar application, it didn't work for me. Also when programmers said to me to have all other Tab Bar applications have to have the same Class file, I can't do that because each of my Tab Bars have their own Class file, as I've said before.
So hopefully, someone can help me with this situation in order to auto rotate the entire Tab Bar, thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在标签栏中的所有视图控制器上返回
YES
。你的代码也可以更短,只是这样:
You need to return
YES
on all view controllers in the tabbar.Also your code can be shorter, just this:
您知道您在第一行中从该方法返回 YES (在纵向的情况下)或 NO 吗?
you are aware that you return YES (in case of portrait orientation) or NO from this method in the first line?