【发布时间】:2014-05-21 09:19:01
【问题描述】:
我有一个主要的viewController A 和一个UITabBar。我的问题是,当我滚动到最后一个单元格时,当我通过UITableView 中的单元格单击转到viewController B 时,当我回到我的viewController A 时,我的最后一个单元格在底部被切断并且我可以滚动显示该单元格的所有内容。但默认情况下,底部的UITableView 与上次不同。
当我启动 viewController B 时,我在 VCB "viewWillAppear" 中使用此代码隐藏我的 UITabBar:
- (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;
}];
}
当我回到我的viewController A 时,我会在 VCB "viewWillDisappear" 中使用此代码显示我的 UITabBar:
- (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;
}];
}
我在 iOS 6 中遇到了同样的问题,但滚动条不允许滚动到底部,并且最后一个单元格总是被切断。
在我的viewController A 在“viewWillAppear”中,我这样做:
if ([[UIDevice currentDevice].systemVersion hasPrefix:@"7"]) {
[self._tabBarControllerArticle.tabBar setTranslucent:NO];
}
- 点击之前(图 1)
- 当我回来时(图 2)
感谢您提前提供所有答案!!!
【问题讨论】:
-
这不起作用,之后我不显示我的tabBar
标签: ios objective-c uitableview uitabbarcontroller uitabbar