我正在开发一个应用程序,只支持肖像方向在我的Info.plist文件中编写。但当我旋转设备时,状态栏会旋转,但视图不会。我不使用InterfaceBuilder来设置视图和初始窗口,我是通过编程来实现的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = myRootViewController;
[self.window makeKeyAndVisible];
return YES;
}在我所有的观点中,都有这样的方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}我该如何解决这个问题呢?
发布于 2012-09-10 19:14:52
为此,我在Info.plist文件的“支持的界面方向”字段中设置了“肖像(底部主页按钮)”。
另一种方法是从所有视图控制器中删除shouldAutorotateToInterfaceOrientation:的默认实现。
发布于 2012-09-10 19:17:13
尝试添加以下内容:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];致您的:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
在AppDelegate中。
希望这能有所帮助!
https://stackoverflow.com/questions/12350179
复制相似问题