0
我無法讓UIWebView加載我發送給它的URL。在進入我的代碼之前,我想知道URL是以「http://」開頭還是以「www。」開頭?UIWebView不加載URL
我使用的是IBAction爲推到堆棧一個UIView:
(IBAction)goToWebView {
WebViewController *webController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
//set the strings
webController.webTitle = [self Title];
webController.webURL = [self website];
//Push the new view on the stack
[[self navigationController] pushViewController:webController animated:YES];
[webController release];
webController = nil;
}
那麼這裏就是我的WebViewController.h文件:
@interface WebViewController : UIViewController {
IBOutlet UIWebView *webView;
NSString *webTitle;
NSString *webURL;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@property (nonatomic, retain) NSString *webTitle;
@property (nonatomic, retain) NSString *webURL; here
而且我WebViewController.m文件:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *urlAddress = webURL;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
您可以與我們分享的任何進一步信息 - 您的應用程序崩潰了嗎? webview是不是加載URL並保持空白?你是否也能分享你試圖加載的URL? – crafterm 2010-04-20 21:37:51