Question

I have a push segue going from my home UIViewController to a UITabBarController. I need to use a push segue because I require a navigation bar at the top and I can't embed a UITabBarController in a Navigation Controller.

When I preform the initial segue, it goes to the UITabBarController and then creates a small margin underneath the navigation bar and above my content. When I switch tabs, this padding is removed, even when I switch back to the initial tab. Then, when I use the Push Segue's back button, my root view controller looses some constraints: I have a collectionView here that pushes up underneath some buttons on the page. Description of problem

There used to be a weird shift with the buttons, and then now they don't move because I fixed the constraints. However, the constraints on the CollectionView seem good.

constraints

It almost seems more like it could be that the items inside the CollectionView are shifting up, not the CollectionView itself. Is this possible? Could I fix this?

This does not happen when I switch to a Modal segue instead of a push. Any suggestions on how I might fix this strange problem? Or can someone suggest a good way to get a Modal segue working for my TabViewController?

Thanks!!

Was it helpful?

Solution

I finally fixed this by modifying Lord Zsolt's answer here.

- (void)viewDidLayoutSubviews {

if (self.searchBar.frame.origin.y == 20) {
    [self.searchBar setFrame:CGRectMake(0, 0, self.searchBar.frame.size.width, self.searchBar.frame.size.height)];
    [self.ptasksTable setFrame:CGRectMake(0, 44, self.ptasksTable.frame.size.width, self.ptasksTable.frame.size.height+20)];
     }
}

I'm checking if the origin of the first item on my view is y=20, and if so, setting the y origin to 0 and increasing the size of the TableView below by 20 to fill the space.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top