[英]Custom Navigation bar hiding tableview
I have a custom navbar on a uitableviewcontroller that hides the table view. 我在uitableviewcontroller上有一个自定义的导航栏,它隐藏了表格视图。
-(void)viewWillAppear:(BOOL)animated{
UINavigationBar *myBar = [[UINavigationBar alloc] init];
CGRect navBarFrame = myBar.frame;
navBarFrame.size.height = 64;
navBarFrame.size.width = self.view.frame.size.width;
myBar.frame = navBarFrame;
[self.view addSubview:myBar];
}
When i try to remedy this by making the navbar not translucent: 当我尝试通过使导航栏不透明来解决此问题时:
myBar.translucent = NO;
the tableview doesnt automatically shift down, and when i try to offset the tableview: tableview不会自动向下移动,当我尝试抵消tableview时:
[self.tableView setContentInset:UIEdgeInsetsMake(64,0,0,0)];
it offsets the navbar as well since it is a subview of the uitableview. 由于它是uitableview的子视图,因此它也会偏移导航栏。
How do i fix this? 我该如何解决?
Also im doing this without storyboards. 我也没有情节提要进行此操作。
Add the below lines of code in your viewDidLoad() method. 在viewDidLoad()方法中添加以下代码行。
self.edgesForExtendedLayout=UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars=NO;
self.automaticallyAdjustsScrollViewInsets=NO;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.