0

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?

Peter Wong
  • 421
  • 4
  • 10
  • are you creating a browser from scratch or it's WebView? – Umair A. May 12 '11 at 13:00
  • [How to take a screenshot programmatically](http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically) – Alex Terente May 12 '11 at 13:26
  • In the "home page" of my browser, there is no any UIWebView. Let me give you an other example of what I want to achieve. Let's say there is a view having only 1 imageView and 1 textField. When a user type in an url link in the textField, the imageView will display the screenshot of that link, how can that be possible? – Peter Wong May 23 '11 at 11:45
  • It's a bit off-subject so I put that in a comment, but "building a web browser for the iPhone" specifically falls under the "duplicate functionality" rule of Apple, that they refused Firefox-Mobile on. Congratulations, you just made a duplicate question while building a duplicate application. I hope you are peer-coding :p http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically – Kheldar Aug 31 '11 at 12:35
  • not sure why you guys keep telling me how to take a screenshot, I wanted to know how to generate something like a website screenshot thumbnail given that the website is not showing on screen. btw, about that "duplicate functionality" rule, building a web browser doesn't mean it will work exactly like safari, look at Chrome, Opera and Dolphin, they all have their unique features over safari and are very popular. – Peter Wong Aug 09 '13 at 04:04

1 Answers1

0

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.

Peter Wong
  • 421
  • 4
  • 10