iOS transition between two html files on a uiwebview - iphone

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.

Related

UIWebView Inside UIScrollView Html Links Not Working

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.

Is there any way to update UIWebView without getting white background?

I have a UIWebView and I want to update it's content from time to time. But when I update a content I got white background while data is loading (data include html with few JavaScripts inside). Is there any way to do it without delay?
I thought about next solution: I have 2 webViews (webView and backgroundWebView). When I need to update webView I just make a request to backgroundWebView, wait until data loaded and replace webView with backgrounWebView's content. But I do not find any solution how to replace it's content
Any advice? Thanks
Try this...
initially in viewWillAppear make UIWebView hidden and then use webview delegate method as webViewDidFinishLoad. In this webview delegate method make your UIWebView visible.
For example
-(void)viewWillAppear:(BOOL)animated
{
webView.hidden=YES;
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
webView.hidden=NO;
}
You can also use UIView with any colour or UIImageView behind your UIWebView. so when your UIWebview is getting loading then it will hide and you will see its behind UIView or UIImageview
You can have dummy UIView as a placeholder and put UIWebView inside the UIView with the same size as the UIView, and replace the UIWebView using removeFromSuperview/addSubView whenever needed.
I think you're on the right track with having 2 UIWebViews, but instead of trying to pass the HTML contents of the background view to the foreground view, you should wait for the second webview to finish loading and then move it on top of the first web view with bringToFront:.

Can we add UIbuttons, uilabels on to webview and make them scrollable along with the web view in iPhone?

I was working on webview. I am facing an issue where I want to display html as well as UIbuttons.
I made webview added Ui butons but when I scroll webview the webview scrolls but the uibuttons remain at the same location.
I've not actually tried this, but in theory this should be possible on iOS 5. If you just add the button to the UIWebView it won't work - as you'll find, when you scroll the views you add remain in place. In iOS 5 Apple added the scrollView property to UIWebView, so if you add your views to that instead (the scroll view) you may find it works?

Editing HTML in UIWebView

I am loading an HTML file in my UIWebView and displaying it in my app. Now I want to all the user to edit this html in the UIWebView real time (i.e. when he is viewing it in the UIWebView). To put it in a different way; Does UIWebView allow editing it's HTML content like a UITextField or UITextView does?
No. It doesn't allow HTML editing.
The closest solution I think of is getting the HTML content and put it in a UITextView but that wouldn't be very user-friendly.
How about split the screen into two view. Web view and text view. Edit text in the text view. When user tap a 'done' button apply the changed text to the web view. Or you can use timer to continuously update web view with the current content of text view.

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?