I have the following controller stack:
- UINavigationController
- UITableViewController
- UIPageViewController
- MyTableViewController1
- MyTableViewController2
- MyTableViewController3
I am using AutoLayout and respecting the layout guides throughout the whole application.
However, MyTableViewController1|2|3 are instantiated inside the UIPageViewController DataSource methods and not through storyboard segues. I'm loading the viewControllers from storyboard using:
[self.storyboard instantiateViewControllerWithIdentifier:#"MyTableViewController1|2|3"];
MyTableViewController1|2|3.adjustScrollViewInsets = YES in storyboard.
But the adjustScrollViewInsets does nothing
In MyTableViewController1|2|3.viewDidLayoutSubViews I log the following:
self.view.frame = {{0, 0}, {320, 568}}
self.bottomLayoutGuide = <_UILayoutGuide: 0x1701b0bc0; frame = (0 531; 0 0); hidden = YES; layer = <CALayer: 0x17022fde0>>
self.topLayoutGuide = <_UILayoutGuide: 0x1781ae700; frame = (0 0; 0 64); hidden = YES; layer = <CALayer: 0x178220ca0>>
It seems I'm just missing some little detail here. Answers I found on stack-overflow are all for autolayout = NO situations.
The problem is MyTableViewController1|2|3's cells render behind the navigationBar.
Any help is much appreciated
Thanks
Related
I have a UIScrollView with an image, and the image is in a container view. The view hierarchy looks like this:
UIScrollView
UIView
UIImageView
Panning works fine, but when I use the pinch gesture to zoom, the image changes size, but doesn't move relative to the origin, so the point centred underneath the two fingers moves as the gesture progresses. This makes it very difficult to zoom in on a particular point, since it's sliding away as you're zooming.
Description of the views involved:
<MyApp.MyView: 0x7ff6fd827e00; baseClass = UIScrollView; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x61800004a4d0>; layer = <CALayer: 0x618000023420>; contentOffset: {684, 487.5}; contentSize: {1731.4584832023011, 1154.3056554682007}>
<UIView: 0x7ff6fbe0c4d0; frame = (0 0; 1728 1152); transform = [2.2028669620902912, 0, 0, 2.2028669620902912, 0, 0]; layer = <CALayer: 0x6180000234c0>>
<UIImageView: 0x7ff6fbe09cd0; frame = (0 0; 1728 1152); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x618000023340>>
I have the UIImageView inside the UIView wrapper because I will have other views overlaid on the image which need to zoom/scale with the image.
There's very little of my own code running during the zoom. The UIScrollViewDelegate returns the UIView (the parent of the UIImageView), and configure the scroll view:
minimumZoomScale = 0.2
maximumZoomScale = 3.0
contentSize = image.size
Well, I've made a simple project that use your structure of views. And I didn't face with the problems. Possibly, you should check this things:are auto layout constraints setting right way is your parent view zooming correctly is mode of UIImageView fitting your needs Hope this may help
I have created a UIScrollView in my Storyboards file, and properly connected it to my controller IBOutlet attribute. Here is what it looks like in Storyboards:
UIScrollView
UIView 1
UIView 2
UIView 3
Constraints
...
This is the code I am running on viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"COUNT: %d", [self.scrollView subviews].count);
for(UIView *v in [self.scrollView subviews]) {
NSLog(#"View: %#", v);
}
}
I was, therefore, expecting to see my 3 views listed in my console log. However, it is printing something totally unrelated (2 UIImageViews?):
2014-09-17 13:06:33.155 Project[6333:652705] COUNT: 2
2014-09-17 13:06:33.156 Project[6333:652705] View: <UIImageView: 0x7b094460; frame = (233 124.5; 7 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x7b0947c0>>
2014-09-17 13:06:33.156 Project[6333:652705] View: <UIImageView: 0x7b094fb0; frame = (236.5 121; 3.5 7); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x7b095080>>
I may be clearly doing something wrong here, but is there some sort of cache in Interface Builder or the Outlet connection itself?
The image views are the scrollers at the edge of the scroll view. When viewDidLoad is called the view hierarchy hasn't been fully installed yet. Move your code into the awakeFromNib method instead (and watch out for the image views - generally don't rely on the subviews, keep explicit references to the views you want to access).
I have used auto-layout and scrollview. I have created hierarchy in storyboard which looks as shown below :
Basically view has scrollview inside it and scrollview has another subview view1 inside it. Rest of the views are under view1.
While debugging one issue I am facing I show that self.scrollView.subviews prints 3 views. Out of them 2 are ImageViews. And those are not subview of scrollview as per the hierarchy in storyboard.
(lldb) po self.scrollView.subviews
<__NSArrayM 0xb66fe80>(
<UIView: 0xb74b110; frame = (0 0; 320 3240); autoresize = RM+BM; layer = <CALayer: 0xb74b170>>,
<UIImageView: 0xb7e61c0; frame = (313 476; 7 3); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0xb7e62a0>>,
<UIImageView: 0xb7e6350; frame = (314.5 3091.5; 3.5 36); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0xb7e6430>>
)
What can be wrong here? Ask for any detail you need.
The UIView on your console is this view
the 2 UIImageView's are the scroll indicators
And one cool thing to debug view hierarchy is recursiveDescription.
po [self.view recursiveDescription]
When I start up my app, the bottom layout guide has these dimensions;
<_UILayoutGuide: 0xd687730; frame = (0 519; 0 49); hidden = YES; layer = >
Which is correct, because my Tab bar has a custom background which isn't transparent. The content of the view controller is a table view.
However, when i go to next tab and go back, the bottom layout has changed:
<_UILayoutGuide: 0xd687730; frame = (0 568; 0 0); hidden = YES; layer = >
What is changing this and why? Any clues please.
IEverything works fine before iOS 6. I have a UIViewController subclass in a UINavigationController as usual. Its view is shrinking down about 20 px as if there is another status bar up top. When I push and pop the view back. The view went back to its correct position. I found out it's because UIViewControllerWrapperView (got by using self.view.superview) frame got wrong somehow in iOS 6.
Doing NSLog in viewDidAppear
At app launch ...
self.view.frame: {{0, 0}, {768, 891}} // was {{0, 0}, {768, 911}} in iOS5.1
self.view.superview: <UIViewControllerWrapperView: 0x9dddb80; frame = (0 20; 768 891); autoresize = W+H; layer = <CALayer: 0x9dddc30>>
// was (0 0; 768 911); in iOS5.1
After push and pop view controller (correct value) ...
self.view.frame: {{0, 0}, {768, 911}}
self.view.superview: <UIViewControllerWrapperView: 0x9dddb80; frame = (0 0; 768 911); autoresize = W+H; layer = <CALayer: 0x9dddc30>>
It never happens before. How does this appear in iOS 6 ?
Here is my current dirty fix in viewDidAppear.
// fix wrong UIViewControllerWrapperView frame by moving up and extending it back
CGRect wvFrame = self.view.superview.frame;
if (wvFrame.origin.y > 0) {
wvFrame.size.height += wvFrame.origin.y;
wvFrame.origin.y = 0;
self.view.superview.frame = wvFrame;
}
There's a better fix than accepted. Try to set wantsFullScreenLayout to YES in viewDidLoad.
self.wantsFullScreenLayout = YES;