IOS>使用POST在Safari中打开URL

我想从UIView发送POST数据在Safari中启动一个URL。 这将允许我加载我的Paypal页面。

通常,在HTML中我们必须这样做:

我知道我可以用以下几行打开一个新的URL:

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http:://I.have.a.beautifull.website.com"]]; 

是否有指定POST数据的意思,或者你有意思吗?

我建议你使用UIWebView实现自定义浏览器。 UIWebView可以加载NSURLRequest。 看看下面的代码

 NSString *post = @"yourPostInformation"; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:baseURL]]; [request setTimeoutInterval:60]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:postData]; [myWebView loadRequest:request];