2

I have one main viewController A with an UITabBar. My issue are when I scroll to the last cell and after I go to the viewController B with a cell click in UITableView and when I come back to my viewController A, my last cell is cut off at the bottom and I can scroll for appear all content of this cell. But by default at the bottom the UITableView doesn't keep the same place that last time.

When I launch viewController B I hide my UITabBar with this code in VCB "viewWillAppear" :

- (void)hideTabBar {

    UITabBar *tabBar = self.tabBarController.tabBar;
    UIView *parent = tabBar.superview;
    UIView *content = [parent.subviews objectAtIndex:0];
    UIView *window = parent.superview;
    [UIView animateWithDuration:0.3
                     animations:^{
                         CGRect tabFrame = tabBar.frame;
                         tabFrame.origin.y = CGRectGetMaxY(window.bounds);
                         tabBar.frame = tabFrame;
                         content.frame = window.bounds;
                     }];
}

And when I come back to my viewController A I show my UITabBar with this code in VCB "viewWillDisappear":

- (void)showTabBar {

    UITabBar *tabBar = self._tab;
    UIView *parent = tabBar.superview; 
    UIView *content = [parent.subviews objectAtIndex:0];
    UIView *window = parent.superview;

    [UIView animateWithDuration:0.3
                     animations:^{
                         CGRect tabFrame = tabBar.frame;
                         tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
                         tabBar.frame = tabFrame;

                         CGRect contentFrame = content.frame;
                         contentFrame.size.height -= tabFrame.size.height;
                     }];
}

I have the same problem in iOS 6 but the scroll doesn't allow to go at the bottom and the last cell are cut off always.

In my viewController A in "viewWillAppear" I do:

if ([[UIDevice currentDevice].systemVersion hasPrefix:@"7"]) {
    [self._tabBarControllerArticle.tabBar setTranslucent:NO];    
}
  • Before when I clicked (image 1)
  • When I come back (image 2)

Before when I clicked

When I come back

Thanks for advance for all the answer!!!

Tulon
  • 4,011
  • 6
  • 36
  • 56
Pierre_S
  • 73
  • 3
  • 13

3 Answers3

1

Another way of doing it is to set translucent property of the tabBar to NO like this

// In init or viewDidLoad of tab bar controller
self.tabBar.translucent = NO;

Assuming you're using iOS7 this should adjust your UITableView just above self.tabBar

Pancho
  • 4,099
  • 1
  • 21
  • 32
1

Click your tableViewController where the problem is happening, go to the Attributes Inspector, scroll down and uncheck the "Under Bottom Bars" box.

enter image description here

The selected answer to this question helped me.

Community
  • 1
  • 1
Devbot10
  • 1,193
  • 18
  • 33
0

You missed to assign frame back to your view. See the updated code.

- (void)showTabBar {

    UITabBar *tabBar = self._tab;
    UIView *parent = tabBar.superview; 
    UIView *content = [parent.subviews objectAtIndex:0];
    UIView *window = parent.superview;

    [UIView animateWithDuration:0.3
                     animations:^{
                         CGRect tabFrame = tabBar.frame;
                         tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
                         tabBar.frame = tabFrame;

                         CGRect contentFrame = content.frame;
                         contentFrame.size.height -= tabFrame.size.height;

                         //YOU MISSED TO ADD BELOW LINE....
                         content.frame = contentFrame;
                     }];
}
Apurv
  • 17,116
  • 8
  • 51
  • 67
  • Thanks but with this lines I have a black bar just above my UITabBar, but apparently the cell are good but just behind black bar... Just on IOS 7 and in IOS 6 I have the same behavior that earlier for IOS 7 – Pierre_S May 21 '14 at 09:38
  • How can I remove this black bar without to hide my UITabBar ? @Apurv – Pierre_S May 21 '14 at 09:59