Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content of static cells not appearing UITableView

I have a UITableViewController that has a table view with static cells. I have added some costume cells with UIImageView and UILabel in them. Everything looks fine in the xcode storyboard: enter image description here

since the cells are static I do NOT implement the datasource methods here's my code for the table view controler:

    #import "MainTableViewController.h"

    @interface MainTableViewController ()

    @end

    @implementation MainTableViewController

    - (void)viewDidLoad {
        [super viewDidLoad];
    }

    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    @end

but when I run the code in the simulator the cells' content won't appeare: enter image description here

here's the Scene hierarchy:

enter image description here

like image 644
Reza Shayestehpour Avatar asked Aug 07 '14 20:08

Reza Shayestehpour


3 Answers

UITableView with static cells not showing up for me either - I tried to remove and re-add the segue. Everything was properly set up. The trick....

The trick is to remove the following row, cell, and section methods from your UITableViewController subclass. They are automatically added by Xcode, but if you are using static cells, you don’t want them in your class.

– (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

Once you have removed these methods, your cells will show up correctly.

like image 94
Ronaldoh1 Avatar answered Nov 09 '22 12:11

Ronaldoh1


I think you have problem with constraints! If you have wrong constraint for elements inside cell, elements will not shown!

like image 23
Aryan Avatar answered Nov 09 '22 10:11

Aryan


Please make sure you have selected "Static Cells" in content option of Table View

TableView

like image 5
Aneeq Anwar Avatar answered Nov 09 '22 10:11

Aneeq Anwar