iOS7 - UIWebView with contentInset doesn't show menu - objective-c

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.

Related

How to hide thumbnail bar in QLPreviewcontroller document preview

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

UINavigationViewController changes the behaviour of scroll view in iOS7

I have a 'UIScrollView' that is supposed to display a list of images one next to the other. This is the code I'm using to add each image:
#define SCROLL_PADDING 10
#define SCROLL_DIMENSIONS 50
view.frame = CGRectMake(xValue, SCROLL_PADDING, SCROLL_DIMENSIONS, SCROLL_DIMENSIONS);
[scroller addSubview:view];
However, as shown in the image below, the images are loaded with a vertical offset. After some research I realised that this offset is the same as the height of the navigation bar's height.
Note 1: By default the images cannot be seen. I had to scroll up to make them visible.
Note 2: I shouldn't be able to scroll because the images should fit in the scroll view.
I decided to present the view controller modally instead of pushing it to the hierarchy of the navigation view controller and everything work as expected.
This problem only happens in iOS7. Any ideas why?
I came across this article, which clearly explains various changes in status bars and navigation bars on iOS7
As you can see in both of the images above, the position of the scroll view doesn't change. In iOS6 if the subview's frame doesn't change, it would be moved down to prevent it from underlapping the navigation bar. Since iOS7 it is expected that all subviews will underlap not only the navigation bar but also the status bar, which makes the location (0, 0) the top left of the SCREEN.
For some reason that I don't understand yet (it would be nice if somebody could explain), only the scroll view's subviews where moved down in the same way it was being done in iOS6. Hence making the subviews appear out of the scroll view's bounds.
To prevent the subviews from underlapping the navigation bar it is necessary to set edgesForExtendedLayour to UIRectEdgeNone as early as possible in the life cycle of the view controller
viewController.edgesForExtendedLayout = UIRectEdgeNone;

How do I fix empty 44px space in iOS7 view with ViewDeckController?

I am in the process of transitioning an app to iOS7. All of the views throughout the app have a 44px empty space at the bottom that appears to be for a bottom toolbar or something, but I am not trying to display a bottom toolbar. This space also exists on views that do have a bottom toolbar and the toolbar just shows directly above it.
The red space shown is actually a view behind the black view. No matter what size I set the frame of the black view to, the red space is always shown. I am also hiding the status bar in plist, so don't know if this is an artifact from that or if it has something to do with navigation bar as they are both normally 44px in height.
I have looked at the transitioning guide and haven't found anything that's worked. Any ideas to what could be causing this and how to fix?
UPDATE:
I have tried setting edgesForExtendedLayout = UIRectEdgeAll and extendedLayoutIncludesOpaqueBars = YES (also tried NO) with no effect. When I look at the subviews of the navigation controller it shows a UIToolBar as hidden, but shows it contains a frame in the exact area the view refuses to resize to even with autolayout constraints.
UPDATE 2:
This is actually a problem with ViewDeckController (https://github.com/Inferis/ViewDeck) and the way it sets it's center view bounds.
I believe it has to do with the UINavigationBar. Try toggling the following options in Storyboard and see if it solves the problem. Namely, the 'Extend Edges' options:
These options can also be set in code with the edgesForExtendedLayout and extendedLayoutIncludesOpaqueBars properties on UIViewController.
If you are transitioning to iOS 7, you should be using an Auto Layout constraint to anchor to the Bottom Layout guide. Control drag from your view to the Bottom Layout guide and choose Vertical Space from the popup menu.
Using frames in iOS 7 is harder and is the way of the past.
Auto Layout is hard to grasp at first, but it is very powerful once you get the feel.
This is actually a problem with third party library ViewDeckController (https://github.com/Inferis/ViewDeck) and the way it sets centerViewBounds for IIViewDeckControllerIntegrated. I was able to figure it out after changing to IIViewDeckControllerContained and seeing the view sized correctly.
In IIViewDeckController.m, just return self.referenceBounds for iOS7 like it does for IIViewDeckControllerContained.

Re-size UIWebView after displaying UIToolBar

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

UIToolbar above UIWebView inside UIScrollView

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.