gpt4 book ai didi

ios - View Controller 在 iOS 7 中不旋转

转载 作者:可可西里 更新时间:2023-11-01 04:52:43 24 4
gpt4 key购买 nike

我的应用程序在 ios 6 中运行良好。但是当我将我的应用程序升级到 ios 7 时, View Controller 不旋转。我已将 rootviewcontroller 设置为 mainviewcontroller。self.window.rootViewController=mainViewcontroller;iOS 7 中的哪些更改使我的应用程序无法旋转......?

最佳答案

这是我在 xcode 4.6 和 xcode5-DP6 中测试过的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];

self.window.rootViewController = navigationController;//self.viewController;
[self.window makeKeyAndVisible];
return YES;
}

在 ViewController 中我插入了下面的测试方法

- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
NSLog(@"rotated");
}

通过使用上面的代码,旋转没有问题。它在各个方向完美旋转。

检查您的定位方法以解决此问题或发布一些代码片段。

注意:我已经在 Xcode4.6 中创建了示例应用程序。

关于ios - View Controller 在 iOS 7 中不旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18820094/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com