开发者

Objective C: Part of UITableView hidden by Tab bar controller

Hi I have a Uitableview add开发者_开发问答ed to a Uiviewcontroller as seen in the code below. The controller is part of a UITabbarcontroller.

The problem here is that the tab bar (at bottom of screen) overlaps with the table view. Is there any way to shorten the table height so that it is not partially hidden by the tab bar?

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view = [[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];

    self.feedTableView = [[UITableView alloc]init];

    self.feedTableView.frame = self.view.bounds;

    self.feedTableView.delegate = self;
    self.feedTableView.dataSource = self;

    [self.view addSubview: self.feedTableView];

    [self getData];

    [self.feedTableView reloadData];
}


You have two problems here:

  • You set self.view in viewDidLoad (it should already have been set in loadView).
  • You set the view frame to applicationframe, but your view does not take up the whole applicationframe (the tab bar controller's view probably does that).

When you have a tabbarcontroller and set viewcontrollers inside it, the tabbarcontroller sets up all the viewcontrollers (tells them when to load and what size to have and when to show). You should never need to set the view's frames in this case. So removing that first line after [super viewDidLoad]; should fix your problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜