iOS方向问题

我有一个简单的networking应用程序,即时通讯使用本机构build。

MainWindow.xlb与我的应用程序consic充满了本机视图控制器。

在本地视图Controller.mi中有以下代码:

http://pastebin.com/xXFc0JCW

看着凌乱的复制和粘贴在这里。

我似乎无法理解我要去哪里错了,为什么我的应用程序/ UIWebView始终保持肖像。

我新开发的iOS。

完整的源代码: https : //www.dropbox.com/s/i9woti5ptecr9n4/Native.zip

现在它工作:

NativeAppDelegate.m

#import "NativeAppDelegate.h" #import "NativeViewController.h" @implementation NativeAppDelegate @synthesize window; @synthesize viewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch [self.window setRootViewController:viewController]; return YES; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end 

NativeViewController.m

 #import "NativeViewController.h" @implementation NativeViewController @synthesize webView; // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"login" ofType:@"html"]; NSData *htmlData = [NSData dataWithContentsOfFile:filePath]; if (htmlData) { NSBundle *bundle = [NSBundle mainBundle]; NSString *path = [bundle bundlePath]; NSString *fullPath = [NSBundle pathForResource:@"login" ofType:@"html" inDirectory:path]; [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]]; } } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // eg self.myOutlet = nil; } - (void)dealloc { [webView release]; [super dealloc]; } @end 

而且我还取消了在InterfaceBuilder中WebView中的ScaleToFill的检查,否则你不得不滚动页面来查看你的Hello World。

我删除了方向的方向,并将您的Window的RootviewController设置为您的ViewController。 你的窗口没有RootVieController。

坦率地说,我没有看到你的代码sniplets中的任何问题。 然而,最近有一个变化,引入了iOS6。 如果我没有太大的错误,那么应该不会再为使用当前SDK构build的应用程序调用RotateToInterfaceOrientation。 而不是你在info.plist中定义支持的接口方向,并可能通过覆盖方法supportedInterfaceOirentations覆盖您的视图控制器中的设置,这将返回一个整数位掩码(如何现代… 🙂

从文档:

处理视图旋转在iOS 6中,您的应用程序支持您的应用程序的Info.plist文件中定义的界面方向。 视图控制器可以覆盖supportedInterfaceOrientations方法来限制支持的方向列表。 通常,系统仅在窗口的根视图控制器或呈现的视图控制器上调用此方法以填充整个屏幕; 子视图控制器使用父视图控制器为其提供的窗口部分,不再直接参与有关支持哪些旋转的决策。 应用程序的方向遮罩和视图控制器的方向遮罩的交集用于确定视图控制器可以旋转到哪个方向。

如果我在这里错了,请纠正我。