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

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

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

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


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

@end


我还取消了InterfaceBuilder中WebView中的ScaleToFill的检查,否则您必须滚动页面才能看到自己的世界。

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

关于ios - iOS方向问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14355028/

10-12 00:19
查看更多