开发者

Use UIWebView Private API?

I want to make a Browser like Safari with UIWebView, which can show the loading progress of the web page. And I saw an app "Downloads Lite - Downloader & Download Manager" selling in app store (http://itunes.apple.com/app/id349275540?&mt=8) that can do this. It also can customize User Agent of r开发者_高级运维equest, even get "content type" of Response Header to decide whether it's needed to be downloaded.

But it seems that it's impossible to make it happen with the public APIs of UIWebView, so I'm wondering how he did that. Could you give me some tips about this?


There is no need for private API to do things like this.

You take a progress indicator for example. By using asynchronous NSURLConnection you can get the size of the expected size of the content you want to download :

-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
{
    [response expectedContentLength];
}

Then you simply compare with the amount of data you downloaded so far.

Customizing User Agents can be done with CFNetwork framework.


have a look at this app/blog: icab.de General approach is to make subclass of NSProtocol and catch all http/https request, that gives you all you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜