Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:45:19+00:00 2026-06-04T23:45:19+00:00

I have a viewController inside of a navigationController , the view controller has a

  • 0

I have a viewController inside of a navigationController, the view controller has a tableview.
In viewDidLoad I set the tableview

- (void)viewDidLoad
{
    [super viewDidLoad];

    // init tableView
    CGRect tableFrame = self.view.bounds;

    _tableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];

    _tableView.delegate = self;
    _tableView.dataSource = self;

    [self.view addSubview:_tableView];
}

The problem with this code is that the table view frame is not correct – the height is 460 and I need it to be 416.

[The iPhone screen height is 480, minus the status bar (20) minus the navigation bar (44) = 416]

So what is the proper way to set the table view so it will fill the screen?
I can think of two ways:

  1. set its frame to = (0, 0, 320, 416)

  2. use: [_tableView setAutoresizingMask:(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth)];

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:45:21+00:00Added an answer on June 4, 2026 at 11:45 pm

    Don’t use magic numbers. Use the resizing flags correctly.
    So yes, your 2. approach is correct.

    1) Use the superviews bounds.
    _tableView.frame = self.view.bounds;;

    2) Set autoresizing flags
    [_tableView setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];

    (you did all of this already 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the navigationcontroller based viewcontroller and I overriding the root view controller navigation
I have pushed a view controller using [self.navigationController pushViewController:myVC animated:YES]; now I am inside
I have a few methods inside my view controller that load up for future
I have a view controller inside a tab bar controller. When I'm inside the
I have a view controller which includes a MPMoviePlayer inside. I hide the navigation
I have a view controller and I want to implement a navigation controller inside
I have a view controller with many views and a tableview. The tableview's cells
I have a class that is viewcontroller and I'v putted it inside of tabbar.
I have a ViewController which is pushed onto the NavigationController stack. As soon as
I have a ViewController that has its own NIB. I would like to embed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.