如何将POST请求插入UIWebView [英] How do I insert a POST request into a UIWebView

查看:91
本文介绍了如何将POST请求插入UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于GET请求,我尝试过这个简单的方法:

For a GET request I've tried this simple method:

      NSString *urlAddress = @"http://example.com/";
      NSURL *url = [NSURL URLWithString:urlAddress];
      NSURLRequest *request = [NSURLRequest requestWithURL:url];
      [uiWebViewThingy loadRequest:request];

(虽然如果请求包含高UTF-8字符,它似乎不起作用。)

(Although it doesn't seem to work if the request contains high UTF-8 characters. )

我想从iPhone发送一个POST。

I want to send a POST from the iPhone.

这也给出了发送POST / GET请求虽然我真的想要do将生成的网页嵌入到UIWebView中。最好的方法是什么?

This also give an overview for sending POST/GET requests although what I really want to do is embed the resulting web page into UIWebView. What would be the best way to go around that?

推荐答案

您可以使用NSMutableURLRequest,将HTTP方法设置为POST,以及然后使用-loadRequest将其加载到UIWebView中。

You can use an NSMutableURLRequest, set the HTTP method to POST, and then load it into your UIWebView using -loadRequest.

这篇关于如何将POST请求插入UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆