Search code examples
iphoneobjective-ccocoa-touchuitableviewios4

Grouped UITableView with multiple sections creating problem in iPhone SDK


In my iPhone app, I am having a grouped table view. I have used viewForHeaderInSection method to change the font color and size of font of section headers.

I have 4 sections in the tableview.

Problem

If there is no data in Section 0 and section 1 then too Section 2 starts to display in table somewhere near center of the view instead of top of the screen.

I want that when section 0 and section 1 cells are empty the section 2 should come at the top of the view as if it is section 0.

How should I proceed?


Solution

  • for this purpose,

    you need to check weather data exist or not suppose you display data from array so,check

    ([array count]>0)

    check this according to you and now,when you return the number of section then you cant

    return 4;[hard code].

    dynamically check data then according to condition return the number of section.