簡體   English   中英

在iPhone應用程序上啟動Safari

[英]Launching Safari on iPhone Application

是否可以在不顯示Safari的情況下打開鏈接? 我的意思是說它是隱藏的

這是我的代碼。

NSString *WebURL = @"http://cvbn-dev.fgrhjnd.com/register.php";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:WebURL]];

將此添加到您的方法:

    NSString *urlAddress = @"http://myurl.com";

//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];

只需檢查您的URL。

我檢查了,但是您的URL無效。

目前尚不清楚是否要顯示網頁並允許用戶注冊(但不啟動Safari),或者是否要收集數據並在后台注冊用戶而不顯示該頁面。 兩者都有可能,但是需要完全不同的解決方案。 Rajneesh071的答案中的WebView代碼是開始的好地方,但是您需要知道,如果您跟蹤Web應用程序中的鏈接,則可能會啟動Safari。 您需要在JavaScript中使用諸如window.location ='newUrl'之類的內容來更改頁面。

如果您要尋找后者,請從看起來像這樣的代碼開始:

NSURL* url = <create your URL>;
NSString* postVariables = <post data in form format>;
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];

request.HTTPBody = [postVariables dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPMethod = @"POST";
[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue]
                       completionHandler:^(NSURLResponse* pResponse, 
                                                      NSData* pData, 
                                                    NSError* pError) 
{ <Process the response> }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM