iOS方向问题 [英] iOS Orientation Issues

查看:160
本文介绍了iOS方向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Web应用程序,我使用本机来构建.

I have a simple web-application that im using native to build.

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

My application consicts of MainWindow.xlb with is filled with Native View Controller.

在Native View Controller.m中,我有以下代码:

Within Native View Controller.m i have the following code:

http://pastebin.com/xXFc0JCW

看上去很乱,无法在此处复制和粘贴.

Looked to messy to copy and paste in here.

我似乎无法理解我要去哪里哪里以及为什么我的应用程序/UIWebView始终保持纵向状态.

I cant seem to understand where i'm going wrong and why my application/ UIWebView always stays portrait.

我是iOS开发的新手.

Im new to iOS development.

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

推荐答案

现在可以使用了:

NativeAppDelegate.m

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

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.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [webView release];
    [super dealloc];
}

@end

我还取消了InterfaceBuilder中WebView的ScaleToFill的选择,否则您必须滚动页面才能看到自己的问候世界.

And I also unchecked ScaleToFill in the WebView in InterfaceBuilder otherwise you had to scroll the page to see your hello world.

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

I removed the Methods for orientation and set the RootviewController for your Window to your ViewController. Your window did not have a RootVieController.

这篇关于iOS方向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆