我有两个UITabBarController
的{{1}},都是在故事板中创建的。
问题在于,在第二个tableview中,表的前几行位于顶部栏下,第一个tableview不会发生这种情况,即使我改变了第一个视图的顺序,第一个将完美地工作第二个会出现问题,因此完美运行的问题现在会出现同样的问题,因为它是tabbar控制器的第二项。
我没有太多要显示的代码,因为我没有以编程方式创建tableviews。
答案 0 :(得分:8)
不确定完全基于您的描述,但会想到几种可能性:
检查IB中的视图控制器属性检查器。寻找 View Controller下的“Extend Edges”选项,取消选中“Under Top” 酒吧“如果被检查。
在ios7中,UIScrollView中似乎存在一种行为 子类,其中内容插入和偏移量自动调整,有时不太好。您 可以尝试在代码或IB中禁用它(请参阅链接 方法:iOS 7 -- navigationController is setting the contentInset and ContentOffset of my UIScrollView)
答案 1 :(得分:0)
对于任何新创建的iOS> 7.0应用,我建议您深入了解autolayout。对于我所有的旧iOS 6应用程序,我解决了这个问题:
在你的UITableViewController界面中:
bool _hasStatusBar;
bool _hasStatusBarHeight;
UIView *_blendView;
在UITableViewController
实施文件中:
-(void)viewWillAppear:(BOOL)animated{
_hasStatusBar = NO;
_blendView = nil;
[self.tableView reloadData];
}
-(void)viewWillDisappear:(BOOL)animated{
_hasStatusBar = NO;
_blendView = nil;
}
- (void) viewDidLayoutSubviews {
// WTF APPLE!?
if (!_hasStatusBar) {
int topBarOffset = 20;
_hasStatusBar = YES;
// Fix for iOS 7 overlaying status bar
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect viewBounds = self.view.bounds;
_blendView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewBounds.size.width, topBarOffset)];
[_blendView setBackgroundColor:COLOR_MAIN];
[_blendView setOpaque:YES];
[_blendView setAlpha:1.00];
UIView *whityMacWhite = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewBounds.size.width, topBarOffset)];
[whityMacWhite setBackgroundColor:[UIColor whiteColor]];
[whityMacWhite setOpaque:NO];
[whityMacWhite setAlpha:0.80];
[_blendView addSubview:whityMacWhite];
[self.view.superview addSubview:_blendView];
}
}
}