I am using a page view controller to flip through a series of view controller, each of which is instantiated from a storyboard. I basically used the standard page based application code as a basis and built what I needed on top of it. The view controllers I'm flipping through are UITableViewController subclasses or custom view controller's that contain custom scroll views or what not.
The page view controller is embedded in a navigation controller, but none of the view controllers are respecting the top layout guide, even though the constraints are set to the layout guides in the storyboard in the case of my custom view controllers and I thought that the table view controller would manage this automatically. I mean the view's contents start from (0.0, 0.0) instead of where the user can see it. The only thing that works is actually setting the frames of the view controller's views to begin just under the status bar + the navigation bar, but I want the scroll view's to scroll under the transparent navigation bar.
What am I doing wrong or not doing?
It sounds like you don't want your content view controller's to underlap the navigation and status bars. If that's the case, try setting parent view controller's edgesForExtendedLayout property to UIRectEdgeNone.
// implementation of page view controller's parent view controller
- (void)viewDidLoad
{
[super viewDidLoad];
self.pageViewController = ...
...
self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7 only
}
For me, setting automaticallyAdjustsScrollViewInsets = NO; on the UIPageViewController fixed the issue. You can change that in the Interface Builder, under Attribute Inspector, uncheck "Adjust Scroll View Insets".
On storyboards:
Uncheck values in parentviewcontollers "Extend Edges" section
Related
I have a problem with the navigation controller and the view. However, I have created a view with a constraint: "Top Space to: Top Layout Guide : 0". I get this result with the simulator:
How to get the view correctly?
Thank you!
EDIT :
The problem is the top of the view is hidden by the navigation controller. On my screenshot, you can see that the segmented control is cut ! The top of the view is not show, even in the storyboard file.
Use edgesForExtendedLayout property to report which edges of your view controller extend underneath navigation bars or other system-provided views.
self.edgesForExtendedLayout = []
Select your view controller from stoaryboard,then unselect the
Adjust Scrollview Insets
Please see the dashed-box area, this is extra space appearing between navigation bar & table view.
I've tried 3 things but same problem.
1. Cleared all constrains & "Add missing constrains"
2. I've used pin, & keep '0' distance to UI object above table view
3. I've used dragging method, & set vertical spacing for table view.
You nee to uncheck the property inside attribute inspector Adjust Scroll View Insets using storyboard see image below.
Edit:
Adjust Scroll View Insets: Defines a Boolean value that indicates whether the view controller should automatically adjust its scroll view insets.
The default value of this property is true, which lets container view controllers know that they should adjust the scroll view insets of this view controller’s view to account for screen areas consumed by a status bar, search bar, navigation bar, toolbar, or tab bar. Set this property to false if your view controller implementation manages its own scroll view inset adjustments.
Select View Controller and Check Adjust scroll View insets.
I've done it, I was placing table view under navigation bar, now I've placed it exactly touching upper bounds of the view. And added missing constrains. enter image description here
Use this line in your tableview class's viewDidLoad method,
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
This sets the content from top.
It will be helpful for you.
-(void)viewDidLoad{
[super viewDidLoad:animated];
self.automaticallyAdjustsScrollViewInsets = NO;
}
By adding following line in viewDidLoad will solve this issue
self.navigationController?.navigationBar.translucent = false
I had an UIPageViewController embedded in a NavigationController embedded an TabBarController.
I supposed every child view of the UIPageViewController fits the size within the UITabBarViewController.
The first child view looks fine:
Switch to the next (vertically), it's view suddenly resizes and the view length expands over the bottom bar:
Actually it's not under the bottom bar but clipped to that size (which means if you pull up the view you still cannot see the whole but the cut text).
I did unchecked every related view controller's Under Bottom Bar & Adjust Scroll View Inset but nothing works.
Any suggestion would be appreciated.
Try this in table view controller viewDidLoad() method.
self.extendedLayoutIncludesOpaqueBars = NO;
OR
you can set property in Interface Builder:
Uncheck Extend Edges: Under Bottom Bars, Under Opaque Bars.
I set up a tableView with the Interface Builder and put a red View above the TableView like this:
But while runtime the red View gets hide by the Navigationbar, so i have to set a constraint with Autolayout like this:
But that can not be correct...what i´m doing wrong?
More Information which my help:
This is because iOS7 allows views to be displayed beneath it. You need to use an offset to push the view down below the navigation bar like you are doing. You could also set the navigation bar to not allow items beneath it by unchecking
under top bars
If you use xibs instead of storyboard add this into your view controller.
self.edgesForExtendedLayout = UIEdgeRectNone;
I haven't been to find anything about this, and it may be that there is no easy solution.
I have a scroll view (in this instance a UITableView) which is the first subview of my UIViewController's view (which is not itself a scroll view). This view controller is in a UINavigationController, and I have also added a UIToolBar as second subview of the view controller's view. Both the table view and the toolbar are positioned and sized in the view controller's view using autolayout (with the table view filling the view, and the toolbar being pinned to the bottomLayoutGuide of the view controller).
As I understood it, navigation bars and toolbars (which are pinned to the bottom of views) should influence the topLayoutGuide and bottomLayoutGuide of the view controller, and by this influence the contentInset of contained scroll views.
The navigation bar is being taken into account (by the topLayoutGuide and automaticallyAdjustsScrollViewInsets) so that my table view content scrolls underneath it, but is visible below it, but my UIToolBar is not - either by bottomLayoutGuide or automaticallyAdjustsScrollViewInsets. This behaviour is the same even if I position my toolbar with a frame (not using constraints).
Am I right in thinking that a UIToolBar pinned to the bottom of the view controller's view should be taken into account by the layout guides? If so, does anyone have any ideas as to why it is not?
If not, is there anywhere (amy method) where I can manually add the tollbar frame to the bottomLayoutGuide so that it is automatically propagated by automaticallyAdjustsScrollViewInsets? And if not, in what method is it best to manually set the table view's content insets?
If you added one yourself it would just be a subview and would not affect the layout guides. Use the built in UIToolbar by setting the UINavigationBar .toobarHidden = false property. Then set the UIViewController.toolbarItems = ...
This toolbar will be your bottom layout guide