简体   繁体   中英

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 request, 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.

看看这个app / blog:icab.de通用方法是制作NSProtocol的子类并捕获所有http / https请求,这将为您提供所需的一切。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM