【发布时间】:2011-06-17 18:47:22
【问题描述】:
我有一个加载 html 文件的 UIWebView。一旦用户单击链接,我希望 url 在自定义 UIWebview 中打开。 我尝试了一些东西:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"MyiPadHTML"
ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:htmlPath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}
else {
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"MyHTML"
ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:htmlPath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}
这是我,根据设备加载文件。这很好用。我在- (void)viewDidLoad方法中做到了
【问题讨论】:
-
您的意思是您希望它加载到不同的
UIWebView对象中? -
是的。在不同的自定义 UIWebview 中。
标签: ios xcode cocoa-touch uiwebview