I have an app that uses navigation controllers and a tab bar controller. So my view controllers all have navigation bars and tab bars.
When I add a UITableView to a UIViewController, then run the simulator for a 3.5-inch screen, the following happens
The top of the table doesn't start at the of the UIViewController (right underneath the navigation bar)
The bottom content (if I had more than one page and scrolled to the bottom) gets cut of
If I use a style == Grouped, then the top header always gets cut off
To see what I mean, try these steps:
Create a new file of type UIViewController with a xib
Make sure AutoLayout is checked
In interface designer, set simulated metrics to have a translucent top bar and a bottom tab bar.
Add a UITableView to the cell
Add some data in it so you can see the data and scroll
Run the app
Can anyone help provide guidance as to how to fix these issues? Are y'all getting these problems too or is it just me?
Assuming it reproduces on iOS 7 place that in your's view did load:
- (void)viewDidLoad {
[super viewDidLoad];
// To support iOS 6
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
}
Related
I am working on Xamarin Studio with Mono but you can respond in Obj-C or Swift I don't mind. (Please don't mind the icons, design, translations, etc on the screenshots this is WIP)
I have this strange issue I can't resolve :
A white blank space appears under the top bar of my UIView which is in a UITabBarController, at first I thought it was the "Adjust Scroll View Insets" option enabled but it is not. I also tried to remove my UIWebView and try with a Label, same problem.
The blank space only appears on views that are "tabbed" in the "Others" section of my UITabBarController (when the screen is too small). You can see on my screenshots on an iPad the white space is not here, but on every other devices (iPhone, iPhone plus) it appears !
I can put a negative top constraint if the device is not an iPad but it is not the proper way to remove it ...
You can find the screenshots of (in order) :
The storyboard view
Top Constraint of the WebView
The whitespace on iPhone (but not on iPad and Storyboard, shouldn't be here !!)
StoryBoard structure
No whitespace on iPad (this is the normal behaviour, I want it on smaller devices too)
ViewController parameters
That by sight the white space is exactly the nav bar is a giveaway that in adjusting for those bars something is awry.
There is a contradiction in your layout that is probably the source of the issue. You have "extend edges" selected for the map view, but you have the top of the map view constrained to the top layout guide. The top layout guide is located at the bottom of the nav bar, so if something was adjusting insets for being under the bar, and knew the bar height and assumed it was under the bar, then this would result.
That wouldn't explain why it looks correct when included in the tab bar's initial view controllers, but it's possible when it appears from more pop-up, it is added to the view hierarchy so quickly it doesn't know the exact position of the top layout guide or the top bars, and so causes the glitch, whereas in the tab bar controller tabs it makes that adjustment on one of multiple layout passes.
Thank you for your answers, I found out what was that white space.
If I want to remove it I have to uncheck "Extent edges - Under Top Bars" and then do (or the NavigationBar will be gray, see Dark shadow on navigation bar during segue transition after upgrading to Xcode 5.1 and iOS 7.1):
NavigationController.NavigationBar.Translucent = false;
But trying to resolve the issue, I tried the following code :
ParentViewController.NavigationController.NavigationBar.Translucent = false;
And the white space turned into a second NavigationBar with tools to reorganize the tabs, and no need to uncheck "Extent edges - Under Top Bars" (especially if you don't set the tranlucent to false because the second navigation bar will go under it).
I will keep that second NavigationBar (https://developer.apple.com/reference/uikit/uitabbarcontroller/1621183-morenavigationcontroller), I like it. But for some reason it wasn't displayed until I set the ParentViewController NavigationController NavigationBar Translucent to false ... I don't really get why, it should have appeared directly but ...
Note that the proper way to display this NavigationBar if it is not displayed by default is to add the line in the UITabBarController class, and not in each ViewController ...
public partial class TabBarController : UITabBarController
{
public TabBarController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
CustomizableViewControllers = null; //if you want to disable the edit button
NavigationController.NavigationBar.Translucent = false;
base.ViewDidLoad();
}
}
(Sorry for the french on the screenshots my device is in French ..)
Have a following structure:
UIViewController (VC) with some UIViews(views) on the top half of screen and UITableView (tableView) on the bottom half of screen. All are on the same hierarchy level within VC's view.
VC is managed by UINavigationController.
Auto-layout is off. Using autoresizing masks.
dataSource and delegate methods are set up and works fine.
What I want to realize:
Hide a navigation bar when scroll up and show in after the scroll down.
What I did:
Since my project supports iOS8+ only, just setting:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
self.navigationController.hidesBarsOnSwipe = YES;
}
should be fine.
What I have:
Swiping up and down on the views hides and shows navigation bar respectively.
Scrolling tableView makes no sense.
Spent some time on that and found that resizing tableView to make it match to vc's view solves the problem.
Edit:
Is it mentioned somewhere in the docs that table view should be only full screen?
Found interesting thing: even if you didn't set hidesBarsOnTap to YES and try to tap on navigation area (i.e. when it's still hidden after swipe) - navigation bar will show after that. Very annoying if you have any UI elements in that area.
After updating device to iOS 8 the next issues with layout occur.
I have an UITabBarController which contains two UITableViewController embedded in UINavigationController. This is main view.
Also there are several UIViewControllers designed in StoryBoard (not embedded in UINavigationViewControllers). These are secondary views. All of them have "Hide Bottom bar on Push" set to YES. Constraints are set to determine layout.
All secondary views are shown with:
UIStoryboard* sb = [UIStoryboard storyboardWithName:STORYBOARD_NAME bundle:nil];
UIViewController* secondaryView = [sb instantiateViewControllerWithIdentifier:_name];
[navigationController pushViewController:secondaryView animated:YES];
All works fine on iOS7.
But with iOS8 there are some problems when secondary view controller appears:
All pinned to bottom UIViews are shown on wrong places for a moment and then "jump" to correct place. Looks like first position is calculated including bottom bar (which is hidden due to "Hide on Push")
If there is UITableView as subview: top pinned subviews again are show on wrong place for a moment and then "jump" to correct place. Looks like first position is calculated not including navigation bar size. If i remove UITableView from controller - all works fine (except p.1)
Tried to set Simulated metrics for secondary views - did not help.
These "jumps" are really annoying. Would appreciate for any advices.
I had a similar problem with jumping when hiding the tab bar from the Storyboard.
Make sure your bottom subviews are pinned to the superview rather than the Bottom Layout Constraint.
You have to do this from the menu - Editor - Pin - Bottom Space to Superview, because the Auto Layout menu in Interface Builder pins to Bottom Layout Constraint by default.
As far as i experienced iOS 8 have issue in tabbar controller mixed with navigation bar controller .. removing one of them will make it run ok again.
I have xib in which button and uicollectionview appears as follows:
Now, when I run it , it appears as follows:
I want to remove white space above photos. I want to show photos just below from button. I have not marked header section in xib too. But, when I scroll up, the images move upto just below buttton too.This means frame is starting from just below button, but, I am getting extra white space.
So, can anybody help me to remove extra white space?
Add this code to your Controller class
- (void)viewDidLoad
{
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
}
Here is doc for automaticallyAdjustsScrollViewInsets
Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.
I had the same problem. What work for me was to set automaticallyAdjustsScrollViewInsets = NO not only on the ViewController containing the CollectionView but on its parent ViewController too, because the child ViewController was in a ContainerView.
It can be done in the Interface builder too:
Auto adjust scroll view insets
I've seen that with iOS7 when using a UIScrollView and a navigation controller the scroll view has to be all the way at the top of the view. Or the label or image will not be in the right spot when the app is run as seen in this question iOS 7 Navigation Bar and Scroll View are different in storyboard and simulator.
I am wondering is there a way around this. I am setting my scrollView like this:
viewController.h
#property(nonatomic,weak) IBOutlet UIScrollView *scrollview;
viewController.m
- (void)viewDidLayoutSubviews {
[scrollview setContentSize:CGSizeMake(0, 1000)];
}
My question is is there a way around this using ios7 and auto layout? Or do I just have to live with it looking weird in the storyboard?
Thanks in advance for the help.
In the Attributes Inspector, under Simulated Metrics, you can change Top Bar to None. This will simulate your view controller having no navigation bar while viewing in Storyboard. When the application is actually ran, the navigation bar will appear.