简体   繁体   中英

How to take a screenshot of a website

I am building a web browser for iPhone in Xcode and the "home page" of my app is a speed dial page which provide 6 slots for users to add their favorite website. Each slot will then display a screenshot of the website. So what I want to do here is to grab the screenshot from the link input by users, for example, " http://www.google.com ". Is it possible to do this with cocoa touch?

In case anyone want to have a similar function like this, I did find a way to do it but not sure whether it's the best way of doing it. Or maybe now there are libraries or plugins out there that provide this function already.

My solution

After users have entered a website url, you need to create a temporary UIWebView and load the url (do not make it visible to the users). After the UIWebView finished loading, you make the UIWebView visible and then take a screenshot, after that, make the UIWebView invisible again immediately (or simply destroy it). In this case, you will get the screenshot of that website and users won't notice what just happened.

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