I'd like to display a toolbar above a UIWebView but hide the toolbar until the person "pulls it down".
The same functionality can be seen in Safari on the iPhone. When the page loads, the toolbar containing the address is hidden. You must pull it down. In Safari it's possible to scroll up and eventually see the toolbar or scroll down through the page contents.
I've tried placing a UIToolbar and UIWebView inside a UIScrollView but it didn't work.
I've tried setting the UIScrollView to the size of the toolbar and webview combined, but that didn't work.
- (void)viewDidLoad{
CGSize size = CGSizeMake(webView.frame.size.width,
toolBar.frame.size.height + webView.frame.size.height);
[scrollView setContentSize:size];
}
How should I go about doing this?
EDIT
Anyone looking at this should consider that the question and accepted answer are both old and that the API might have changed to allow this.
The UIWebView is itself a UIScrollView so it's not going to work. I'm not sure how Apple does it, but one way to do it, if you have control over the content of the web view, is to write some HTML and CSS that replicates that address bar.
Related
I need to hide the thumbnail bar on double tapping the document preview. But if I add the QLPreviewcontroller as a subview, the double tapping is not working and the thumbnail bar is not hidden. I need to do this because the bar is hiding a right side part of the document. Please suggest me some way how to handle this.
If I present it as a viewcontroller I don't face any issue. But am not able to add a toolbar or edit the navbar of QLPreviewcontroller .
I need to also add a customized Toolbar to this viewcontroller.
Just found it, same issue, in fact generally as soon as you add a view from an another view controller inside a master view controller, you need to declare the child view controller as child :
[self addChildViewController:quicklookVC];
[quicklookVC didMoveToParentViewController:self];
then now tap to hide / show option bar and thumbnail preview is working
I've been struggling with first responder problem. I put web controller (UIWebView) inside UITableViewCell and now I would like to scroll vertically my table and not affect UIWebView (this case may be done by disabling scrolling scrollview from UIWebView). However problem appears when user zooms into web content, then I want scroll horizontally through web content and still vertically scroll in table (cause cell will be resized to zoomed content).
There is a property called 'multipleTouchEnabled' that should disable the pinch gesture, but I think the user would still be able to double-tap (assuming the cell doesn't consume this gesture). Why not, instead of creating multiple UIWebView's (which have a large overhead) don't you create one hidden UIWebView that loads a website and caches an image, then load this image into the cell.
Ultimately, if you still wanted to use the UIWebView approach, you could probably subclass it and override hitTest/touches methods or handle the gesture recognizers yourself.
Also, if this is for iOS8 I would be using the WKWebView instead.
I have a UIWebView that allows for content to be edited with another UIView included in the UIScrollView of the UIWebView. This creates a header above editable content. The editable content is positioned using a contentInset on the scrollview so that it's positioned correctly below the header.
Now - what I'm finding is that when the scroll view of a UIWebView has a contentInset applied to it that is > 0 then the menu that is shown (cut/copy/paste) etc is only shown when the insertion point from the top of the content inset is greater than the absolute value of the content inset.
So let's say the content inset is 100px. This means that the menu is only shown when the insertion point is > 100px from the start of the contentInset.
This is a regression from iOS6 where the menu was always shown. The same code shows the menu on iOS6, but when built for iOS7 it does not show the menu.
The only way to get the menu to appear is to move the insertion point down in the body of UIWebView.
Has anyone seen this or know of a fix to this problem? The only fix I can find is not to specify a contentInset which then of course breaks the app's usability...
- (void)viewDidLoad
{
[super viewDidLoad];
self.view = self.webView;
}
Works fine for me.
I've got a ViewController with a UIToolBar at the top and a UIWebView underneath. The WebView fills the entire remaining portion of the View and is set to stretch, being anchored at the top and left.
The content of the webpage is 3-4 screens long, but when I scroll down through the WebView, I can see it all. However, if I dynamically hide the UIToolBar, then re-show it again, the WebView ends up being "too big" -- it's actually longer than the space available in the ViewController, so now when I scroll through my 4 pages of content, I get to the bottom and it tends to "bounce back" and won't display the bottom half inch of web content.
Is there a way to re-size the webview after hiding the UIToolBar?
webView.frame = self.view.frame
after the hiding of the nav bar should do the trick. also try
webView.scrollView.alwaysBounceVertical = NO;
to try to eliminate bouncing if it is having an undesirable effect. Cheers!
Resizing the webview isn't really necessary. You should instead play around with the auto resizing masks, like so:
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight
Ok, so I have a UIScrollView that contains several subviews, the subview I am having difficulties with is the UIWebView. When the webview is displayed on screen without having to scroll down the UIScrollView, everything works great (figure 1).
Where the problem starts is when the webview is loaded off the screen (figure 2), and scrolling is needed to view it (figure 3). The webview no longer responds to any user interaction.
I've tried some basic things like reloading the webview after the scrollViewDidEndDecelerating delegate is called, but nothing seemed to work. Has anyone encountered this before or have any suggestions on how to fix it?
Turns out this was working perfectly all along. Only problem was I had a wrapper UIView that contained the imageView and webview, but the wrapper wasn't getting resized, so touches outside its bounds weren't being respected. I just want to mention, a webview really shouldn't be placed in a scrollview. I'm only doing this because the webview is being sized according to its content and has scrolling disabled. Plus, there are currently no other views in the documentation that support links without heavy modification.