gpt4 book ai didi

iOS 方向问题

转载 作者:行者123 更新时间:2023-11-28 22:41:43 25 4
gpt4 key购买 nike

我有一个简单的 Web 应用程序,我正在使用 native 构建。

我的 MainWindow.xlb 应用程序包含 Native View Controller。

在 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,否则你必须滚动页面才能看到你的 hello world。

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

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

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