Objective c 自动旋转选项卡栏应用程序
嘿,伙计们, 我正在尝试自动旋转我的选项卡栏应用程序。显然,我知道大多数人会说这个问题是Objective c 自动旋转选项卡栏应用程序,objective-c,cocoa,xcode,uiinterfaceorientation,autorotate,Objective C,Cocoa,Xcode,Uiinterfaceorientation,Autorotate,嘿,伙计们, 我正在尝试自动旋转我的选项卡栏应用程序。显然,我知道大多数人会说这个问题是返回YES或所有选项卡栏项必须在同一类中才能自动旋转。不,这对我不起作用。首先,我有4个选项卡栏项,每个都有自己的类。我的前两个选项卡栏项有UIWebView,第二个是表视图,最后一个是带按钮的图像视图。现在我练习了为我的第一个选项卡栏项目实现自动旋转代码,这是一个UIWebView,使用此代码,因为返回YES对我不起作用: - (BOOL)shouldAutorotateToInterfaceOrient
返回YES代码>或所有选项卡栏项必须在同一类中才能自动旋转。不,这对我不起作用。首先,我有4个选项卡栏项,每个都有自己的类。我的前两个选项卡栏项有UIWebView,第二个是表视图,最后一个是带按钮的图像视图。现在我练习了为我的第一个选项卡栏项目实现自动旋转代码,这是一个UIWebView,使用此代码,因为返回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;
}
在没有选项卡栏的情况下使用这段代码对我来说是可行的,但是当在选项卡栏应用程序中使用这段代码时,它对我来说是无效的。另外,当程序员告诉我所有其他选项卡栏应用程序必须具有相同的类文件时,我不能这样做,因为我的每个选项卡栏都有自己的类文件,正如我之前所说的
因此,希望有人能帮助我解决这个问题,以便自动旋转整个选项卡栏,谢谢您需要在选项卡栏中的所有视图控制器上返回YES
您的代码也可以更短,如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
您需要在选项卡栏中的查看控制器上返回YES
您的代码也可以更短,如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
您知道您在第一行从该方法返回YES(在纵向定向的情况下)或NO吗
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
// this never gets called:
// if (interfaceOrientation == UIInterfaceOrientationPortrait ||
// interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
// interfaceOrientation == UIInterfaceOrientationLandscapeRight)
// return YES;
// else
// return NO;
}
您知道您在第一行从该方法返回YES(在纵向定向的情况下)或NO吗
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
// this never gets called:
// if (interfaceOrientation == UIInterfaceOrientationPortrait ||
// interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
// interfaceOrientation == UIInterfaceOrientationLandscapeRight)
// return YES;
// else
// return NO;
}
嘿,我还有一个问题,我的UIWebview是一个移动网站,当我向左旋转时,应用程序的整个大小完全向左移动,你知道当它自动向左或向右旋转时如何将这个网站移动到中间吗?body{width:200px;margin:0 auto;}
?嘿,我还有一个问题,我的UIWebview是一个移动网站,当我将其向左旋转时,应用程序的整个大小完全向左移动,你知道当它自动向左或向右旋转时,如何将此网站移动到中间吗?body{width:200px;margin:0 auto;}
?