Blank area at bottom of UITableView

Discussion in 'iOS Programming' started by pinsrw, Oct 19, 2010.

  1. pinsrw macrumors regular

    Joined:
    May 30, 2010
    #1
    Hi all,

    I've set up a UITableView in a navigation-based iPhone app, and I've been surprised to see that there is a blank area within the rectangle of the UITableView. It's about 20 pixels high, or the height of one row.

    I assumed it was the footer but I set up the methods to report a zero footer height and to provide a nil footer UIView, and there is no improvment.

    Anybody know what that blank area is, if it's not the footer?

    Thanks.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    20 pixels is the height of the status bar.
     
  3. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #3
    Well what I mean is, it has these regions:

    Code:
    [Top navigation bar]
    [Some buttons of mine]
    [UITableView line 1]
    [UITableView line 2]
    [UITableView line 3]
    [UITableView line 4]
    [Blank area that is within UITableView rectangle and on-screen]
    
    When I scroll the UITableView, none of the lines (e.g. if there are 20) appear in this blank area.

    Here's something odd: I've found I can place buttons and other widgets on top of this blank area in order to make use of the unused space. Is that to be expected?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    So, you have no status bar in your window, right? So, you need to adjust the size of your table view to take up the space that used to be occupied by that.
     
  5. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #5
    I did that but the lower 20 pixels still aren't used. That's why I put a button and label above that area of the UITextView. Feels like a kludge though...
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    How?

    P.S. And you meant UITableView and not UITextView, right?
     
  7. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #7
    You are right, I misspoke and meant UITableView.

    In the attached screenshot you can see that I have the UITableView selected. The area of the UITableView that is always blank is the lower 20 pixels, so I put a label on top of that area in order to make use of that area.

    When I do command-R in IB, the UITableView works fine. It's only when it's used in the context of the larger navigation app that there's a blank area.
     

    Attached Files:

  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    Well, that's more than 20 pixels high, so there goes my theory. (Also, didn't realize the table was not occupying the entire view.)

    Is this just an issue with how it shows up in IB or do you see the gap with the app running as well?

    Remove the label and attach a new screenshot, along with the Size Inspector settings as well.
     
  9. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #9
    Is the table grouped or plain?

    Are there only four rows in the table?

    Obviously if the height of the table is more than the height of its rows there will be empty space. Is that what you're seeing?
     
  10. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #10
    OK, here's what I've done. I moved the table up and put a label just below it. The background of the label is gray. Running it in IB it's clear that these are adjacent. In the code, I set the background of the table to red so that it's clear where it is. But this also shows the basic problem: When run, the table shortens by about 20 pixels, so now there is the blank area between the red table and gray label, which is the subject of this thread. Thus it appears that something is causing the table to shorten at runtime.
     

    Attached Files:

  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    What are the autoresize settings for your table view? (Which is why I asked earlier for a screenshot of your Settings Inspector as well.)
     
  12. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #12
    Wow... That was it. I disabled "autoresize subviews" in the view and now the table is the size that I specified in IB.

    Thanks for your help on this.
     

Share This Page