2013-06-19 32 views
1
NSString *urlAddress; 
urlAddress = @"http://ob.carptown.net"; 
NSURL *url =[NSURL URLWithString:urlAddress]; 

NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[page loadRequest:requestObj]; 
[page addSubview:activityView]; 
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) 
             target:self 
             selector:@selector(loading) 
             userInfo:nil repeats:YES]; 
goBack.enabled = page.canGoBack; 
goNext.enabled = page.canGoForward; 

UIViewView無法打開上述URL(http://ob.carptown.net)。
我測試了另一個URL並打開它們UIViewView。但是URL可以在Safari中打開。 我想要打開Safari瀏覽器的網址,我想像UIWebView一樣控制Safari瀏覽器。無法打開UIWebView中的特定網址

我該怎麼做?

+0

你想讓webView在應用程序中打開或轉移到獨立的safari應用程序嗎? – MacN00b

+0

我只想打開網址(http://ob.carotown.net)。 – user2499911

+0

不離開應用程序? – Groot

回答

0
NSString *urlAddress = @"http://ob.carptown.net"; 

//Create a URL object. 
NSURL *url = [NSURL URLWithString:urlAddress]; 

//URL Requst Object 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

//Load the request in the UIWebView. 
[yourwebview loadRequest:requestObj]; 

remove NStimer and check it again it will work fine 
+0

它不起作用。 – user2499911

0

如果檢查返回的HTML,服務器給你一個空<body>標籤(除了谷歌分析)。看起來你有JavaScript在頁面加載後呈現內容。 UIWebView似乎無法執行此操作。僅當從橫向和背面改變方向時(Cmd + left arrowCmd + right箭頭相互之間快速移動)纔會重新加載頁面。不幸的是,我不知道爲什麼會發生這種情況