Why is my UITableview Y origin changing based upon the position in TabBarController
Asked Answered
C

3

6

Upon clicking the button on the first screen the user is presented with view controllers contained within a tab bar controller. The view controllers have two tableviews in them, the first a top static table and a second table just below. The view controllers in the tab bar controller that are not within the "more" display correctly. If I go to "more" and select a view controller the view is displayed with the top cell pushed down.

If I go to the "more" screen, click edit, and move the order of view controllers in any way, view controller displayed through "more" display correctly. Upon leaving the "more" section the top table cell (top table) is not displayed.

It seems reasonable to me that there is an issue in the UI or storyboard, however nothing jumps out at me as the issue. I've tried both manually setting constraints and also using suggested constraints.

This sample project is available at https://github.com/propstm/NavigationStructureTest

Top two images are prior to modifying the order of view controllers in the tab bar controller.  The bottom two, after.

Charlyncharm answered 3/7, 2015 at 14:48 Comment(0)
B
2

Disable Size classes,and delete the constraint(top tableView) of "vertically space to top layout guide",add pin top space to super view can solve the problem. Maybe it's a bug of Xcode,see this.

Bart answered 7/7, 2015 at 14:46 Comment(2)
Why downvote then upvote?It's the answer not understandable?Bart
Removing the top layout guide and using the pin worked both in the sample app, and also in my larger client app which had the issue. Thank you for sharing that link -- The solution to the problem was not something I would have come to on my own.Charlyncharm
J
3

I simply updated the constraints in the Two Table VC , then the issue was not there.

top tableview constraints

bottom tableview constraints

Jodeejodhpur answered 7/7, 2015 at 11:16 Comment(3)
What constraints are you using? I've updated the master branch of the sample to not have any issues on the storyboard and the issue still exists for me.Charlyncharm
Those values are not working for me. Having the top space to the top layout guide being -44 is pushing the top tableview below the navigation bar. Would you be able to push a pull request to the sample project?Charlyncharm
i have made a pull requestJodeejodhpur
B
2

Disable Size classes,and delete the constraint(top tableView) of "vertically space to top layout guide",add pin top space to super view can solve the problem. Maybe it's a bug of Xcode,see this.

Bart answered 7/7, 2015 at 14:46 Comment(2)
Why downvote then upvote?It's the answer not understandable?Bart
Removing the top layout guide and using the pin worked both in the sample app, and also in my larger client app which had the issue. Thank you for sharing that link -- The solution to the problem was not something I would have come to on my own.Charlyncharm
P
0

I think it has something to do with the "more" controller provided by the TabBarController having its own navigation controller, and your storyboard set up to extend edges beyond top bars.

Although you are trying to hide the navigation bar, I think its done in the wrong place and should only be required when the item is being presented in the "more" controller. The way its currently implemented confuses the top layout guide, which seems to be left assuming there are two top bars even though one of them is hidden.

I was able to fix your demo project in two ways. By either:

1) Update the storyboard and turn off "extend edges" on the tab bar (and set the tab bar and top bars to be opaque):

enter image description here

OR

2) Simplify the viewWillAppear/Disappear and viewDidAppear/Disappear methods and hide the navigation bar when within the tab bar more controller:

- (void)viewDidAppear:(BOOL)animated{
    //self.navigationItem.backBarButtonItem.title = @"HOME";

    self.tabBarController.title = @"Entity List";

    //Pretty activity indicator
    [self.topTableView reloadData];
}

- (void)viewWillAppear:(BOOL)animated {
    if (self.navigationController == self.tabBarController.moreNavigationController) {
        [self.tabBarController.navigationController setNavigationBarHidden:YES];
    } else {
        [self.navigationController setNavigationBarHidden:NO];
    }
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController.navigationBar setHidden:NO];
}

- (void)viewDidDisappear:(BOOL)animated {
}

This ensures the top navigation appears correctly without messing up the layout guide.

Pancreas answered 12/7, 2015 at 22:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.