Multiple tabs in UIWebView in iOS - ios

I want to use UIWebView in my application.
I want to open up multiple URLs within the same UIWebView. Also, the tabs should be maintaining their own sessions.
Is this possible? If yes, can anyone please help me out with the same..

Related

Tabbed iOS WebKit Browser with Swift

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.

UIDocumentInteractionController Disable Options Menu

I have a PDF showing in a UIDocumentInteractionController and its great.
Problem is, the point of the app is to protect the PDF from being shared etc. Hence I want to get rid of the options button that appears.
There are 1000 similar Q's on stack, but before you go linking me to what I have already read please keep in mind that I need an iOS6 solution.
I have tried implementing the willShowMenu related functions, and a bunch of other stuff.
End of the day, this needs to get onto the store, and we all know how rigid apple are, so if anyone has a solid store-aproved ios6 solution that would be great.
If not, could anyone point me in the right direction and I will work it out. Is there an alternative to UIDocumentInteractionController for display (but copy protecting) PDFs?
Thanks.
You can use UIWebView to display PDF file.
To disable copy menu, Add the following code in the webViewDidFinishLoad delegate of UIWebView
[webView stringByEvaluatingJavaScriptFromString:#"document.documentElement.style.webkitUserSelect='none';"];
[webView stringByEvaluatingJavaScriptFromString:#"document.documentElement.style.webkitTouchCallout='none';"]

ios - how to create a screen with a lot of text and buttons and not use UIWebView

I can not use UIWebView because I want the text to be accessible even if the user does not have Internet access on their phone. Also, I will need to have buttons to other screens on the app and I think that is not possible with UIWebView (right?)
Is there a way for me to edit the xml of the screen directly inside Xcode? My requirement is to have about 10 sections with header labels and buttons before each, so if I have to adjust it on the storyboard screen, it will be a bit nightmarish.
What is a reasonable approach for me here? I think only to edit the xml by hand and hardcode it with styles and text, right?
several things here:
webviews only need an internet connection if you are downloading the content for the view (which doesnt seem like what you want anyway, aren't you just building it locally?)
you can make the buttons in a webview do whatever you want. See this answer.
What is so complex about this UI that you can't just build it the regular way in code or IB?
Just because you consider using a UIWebView it doesn't mean you are restricting your application functionality to internet access.
You can just as well have HTML documents in the application bundle that you display in a webview. This is basically what PhoneGap is doing.
If you don't want to use webviews then nothing is stopping you from using UIViews, UILabels, UIImageViews etc and compose your app how you want.

Difference between content in uiwebview and mobile safari?

I am showing a twitter feed in a uiwebview... however there is a problem: it appears significantly differently in the uiwebview then what it does in mobile safari. Ultimately, I much prefer the look of the feed as it is shown in mobile safari. Is there any way to 'trick' the web view into displaying itself as safari? Possibly by altering the user agent? Thanks.
Ended up altering the user agent. App made it past apple review fine.
UIWeView and Safari doesn't display all the pages as the same..There can be minor differences in formatting in UIWebView which won't be found in Safari..
Solution to this is to use javascript to alter the WebView itself programmatically to display things right..
more info avaialble in UIWebView Class Reference doc here

iOS- How to break down a web content and display it as you want

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.)

Resources