UIWebView Inside UIScrollView Html Links Not Working - iphone

I have added a UIWebView along with some labels inside UIScrollView (using StoryBoards) by adding it as a subview and then setting the ScrollView height to show all the html content of WebView that is loaded in it using loadHtmlString.
The links in the html content are not working. A little searching revealed that Apple does not recommend putting UIWebView inside UIScrollView to avoid unexpected behaviour. But as i also have to add labels and other stuff other than the UIWebView, so i have to embed them inside UIScrollView.
Is there any way I can make the links work in the html content without violating and Apple's recommendation?

There is no reason to put a UIWebView inside a ScrollView. UIWebView will scroll and zoom and pan the content properly as is. It is sort of redundant unless you have some other layout reasons for example combining it with some other views.
The correct way to add your labels is to add them to a UIViewController or NavigationController and have them positioned around the UIWebView and to also add the UIWebView to that as well.

Related

UIScrollView Not Scrolling In iOS 7 StoryBoard

I am trying to add a UILabel along with a UIWebView together in a view controller and want them to scroll together. So to accomplish that, i have added a UIScrollView behind these two views but the UIScrollView is just not scrolling. I am using Storyboard and iOS 7 SDK.
I have seen many questions but they are not of much help. Some are suggesting that i should disable the AutoLayout that i cannot do due to the requirements of my project. What else can i do to make it work? Thanks!
According to Apple's documentation, you shouldn't use UIWebView inside UIScrollView. What you can do is to add your UILabels and UIWebView inside aother UIView and then add this UIview inside the UIScrollView.
Secondly, you have to set the contentSize of the UIScrollView in order for it to work.
You also have to disable the scrolling of UIWebView that is embeded inside the UIScrollView.
Still if your problem is not solved. It is better to just turn of AutoLayout. I have had the same issue and i wasnt able to solve it without disable the AutoLayout.
The documentation for UIWebView states:
Important: You should not embed UIWebView or UITableView objects in
UIScrollView objects. If you do so, unexpected behavior can result
because touch events for the two objects can be mixed up and wrongly
handled.
You need to wrap the label and web view in a regular UIView. Add the regular view to the scroll view.

iOS transition between two html files on a uiwebview

I have one webview that fits fullscreen and loads an html file. Then another html file is loaded and I would like to apply transition between those files. Possible? Switch between two views that contains another webview is not an option due to any other reasons. Thank you.
You may insert a UIWebView inside a UIScrollView. Then when you have to load the new page, you create another UIWebView and its x will be the width of the current UIWebView, then addSubview the new UIWebView to the scrollview, and update the scrollview contentSize. Then call the method scrollRectToVisible:animated of scrollview to the frame of the new web view, this do the transition.
In addition, if you don't want to back to the previous page, you may destroy the previous UIWebview and reset the contentSize of the scrollview as it was initially.
How "another html file is loaded"? By events in the first webpage?
If you are writing the html pages you could use jQuery mobile transition?
See here
Even if you are not writing the html pages you might be able to inject javascript for this.

How to scroll the outside scrollView not inside scrollView?

I have a scrollView and inside it some scrollViews , and everyone have a webview to show html file, using this method I will zooming every html file , but Now I found that when I scroll the html file it didn't work. I think I scroll the scrollview inside and it autosize the html file , but How to let the scrollview inside not to call the scroll function and when I scroll the html it can call the scroll function outside, and I have disable the scroll property of inside scrollview, but it didn't work, and How to do with it? Thank you very much!
UIScrollView in UIScrollView is a common use. See apple stocks app...
I am trying to send ScrollView Gesture events like pan and zoom from outside the scrollview itself. It doesn't look like apple lets you send to the UIScrollViews handlePan: and handleZoom: methods
A quote from UIScrollView Class reference :-
Important: You should not embed
UIWebView or UITableView objects in
UIScrollView objects. If you do so,
unexpected behavior can result because
touch events for the two objects can
be mixed up and wrongly handled
I would add : "You should not embed UIScrollView objects in UIScrollView "

Two resizable UIWebViews inside UIScrollView

I need following view structure, with embedded 2 UIWebViews and 1 UIView (loaded from other xib).
But the problem is, because this need to be inside UIScrollView, with same impression like this is single page. (only vertical scrolling need to be enabled).
In those UIWebViews, html content is loaded from NSString.
Size (height) of UIWebViews and child view is variable.
Any advice, how to do that?
Important: You should not embed
UIWebView or UITableView objects in
UIScrollView objects. If you do so,
unexpected behavior can result because
touch events for the two objects can
be mixed up and wrongly handled.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html
However why cant you make a webview that has two iframes, with the content of your two html-files? Then attach this webview to the uiview?
Iframe resource:
http://www.w3schools.com/tags/tag_iframe.asp

UIWebView content with scrollable iframe

I have a html page with iframes where part of the page is scrollable while other parts are not.
Is there a way to display this in a UIWebView and allow scrolling these iframe sections?
So far I see that only the entire page is scrolling.
No, it's not possible.
The UIWebView is composed by a UIScrollView, the content is rendered inside it.
So, basically what you want is to create an UIScrollView inside an UIScrollView. Dispatching the gestures will be a big challenge. Which one should scroll?