I have a perfect example for what i'm trying to do:
There is a new app called watchville, its an app for watch lovers, and they present rss from several websites in a nice customized way.
This is the page without customization :
This is the page after you click on the button for the customized view :
I did the cover image and all, but I want to customize the actual content...header, body etc and make it look elegant like here..
This is what i did:
Can someone help?
Tnxxx
Try using paginated web page and you can cache data for pages using NSURLProtocol.
It would load pages and cache onto disk so navigation backward would be from cached and only 1 page would be in memory which is being viewed.
That is best you can do with UIWebView OR you may go for MKWebView it can allow you additional features like javascript.
Related
I am trying to code a "webpage selector" on my app, using a fancy carousel to display the webpages thumbnails.
However, I don't want to display the webpages thumbnails as webViews on my carousel because I can get quite a large number (20-30) of webpages at the same time and loading all of those can cause a lot of lag.
So, I decided to use screenshots of the webpages and use those images to populate my carousel instead, making the carousel animation much smoother.
Here is my question:
I would like to know if there is any way to take a screenshot of the webpage (without showing it on the app screen) and save the image into a list that I can use to populate the carousel.
I am aware of this question but is quite an old post, so I was wondering if there is another way to do it. Also, I tried to implement the suggested solution, but it did not work.
You can create a WKWebView that is behind your view controller (and thus invisible) and constrained to the size that you want. Once the page finishes loading take a snapshot by using drawHierarchy(in:afterScreenUpdates:) inside of a UIGraphicsImageRender and save the resulting image as your thumbnail.
In short I am trying to build some typical browser functionalities in a Swift iOS app with WKWebViews (WebKit). I already have a functioning browser based on a WKWebView, which already has a menu bar with a URL input, navigation buttons, a share button, page title etc.
What I am struggling with is creating tabs for the browser. At first this seemed trivial as surely WKWebViews would support this in some way. Well, as far as I can tell they do not (looked at and tried multiple tutorials incl. hackingwithswift, Ray Wenderlich etc. + I checked Apple's documentation + stackoverflow)
This is what I have come up with so far:
1) Creating a new tab/opening a new URL should create a new UIView + WKWebView programmatically (I'll have to make a subclass out of my current browser view)
=> this should create a separate thread for each WKWebView/tab according to Apple's documentation
2) I need something like a Collection View (or Stack Views etc.) to store screenshot images of the already open tabs as a preview page of all tabs. The cells should be linked via a delegate to the corresponding WkWebView and they should have a close button to close (= delete) the tabs.
Am I overthinking this? If I go down this path I have to find a way to wire up (and subsequently delete) multiple delegates and views to the Collection View dynamically and I have to store & delete screenshots every time the user interacts with the tabs. It seems VERY messy. But given that Chrome on iOS is based on WebKit as of late, it's obviously doable.
How would you tackle this problem?
PS I didn't include a mockup because you all know how the tabs in Chrome, Safari etc. on iOS look like.
EDIT:
I am just looking for a clean and sensible way to add/remove and show the multiple WKWebViews, which are created by opening new tabs - just like in Chrome for iOS or Safari etc.
Ok, I have solved this today :) I will have a main UIView and then multiple WKWebViews, which can be "zoomed in" in order to enter full screen mode. No need for screenshots etc.
I am working on a small app to learn WKWebView abilities. I have added a navigation bar at the bottom with back and forward buttons in order to navigate between loaded pages. But if I initialize the view with loadHTMLString instead of loadRequest, then the history buttons are not working. The canGoBack/canGoForward attribute is false.
Is it possible to navigate between loaded html documents in WKWebView if they were loaded with loadHTMLString?
Judging by the documentation, the built in history that ships with WKWebView supports URLs but not blobs of HTML. Have a look at WKBackForwardListItem. It has three properties: title, URL, and initialURL.
You could build this functionality yourself, by implementing a similar list and a similar model. I don't know if WKBackForwardListItem is subclassable, but you can make your own.
im trying to build an application like a book, with so many custom views and intensive animations. i want to know what is the best template for this kind of app? single view, view based?
thanks
I would use a "Page Based Application" it comes with an interface that interacts just like a book with paging effects and everything. It uses one viewController that dynamically replaces content based on which page has been navigated to.
I've been wondering how all the web apps display web content, say on a UITableView. When we call UIWebView instance method loadRequest: it simply surfs away to the link provided with the NSURL object. But how do we further manage all the contents with TableViews, ImageViews and so on. What is the basic principle of web apps in iOS? Do I need to learn HTML and any other web related technology like AJAX,java script etc.?
You don't display the contents of a UIWebView in a UITableView (or UIImageView, etc.) The apps you're likely referring to use one of two approaches:
Download the data using NSURLConnection, usually with REST and JSON. Then display it in a UITableView.
Display HTML content in a UIWebView that looks like a UITableView
For more information on the first case see the URL Loading System Programming Guide. For more information on the second case, see Getting Started with iOS Web Apps.
Most things that could run in MobileSafari can also run in a UIWebView. It is difficult, however, to get native, correct behavior for all your UI elements using a UIWebView. Button taps in particular do not work correctly in most web apps. Swipes also can behave non-optimally. But even so, many "apps" out there are actually just web pages in a UIWebView. (The Facebook app is a good example of this.)