Static Cell Content Not Displaying UITableView

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

since the cells are static, I DO NOT implement the data source methods here, my code is for the table view controller:

  #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 contents of the cells will not look: enter image description here

here is the scene hierarchy:

enter image description here

+6
source share
8 answers

I think you have problems with restrictions! If you have the wrong restriction for the elements inside the cell, the elements will not be displayed!

+5
source

UITableView with static cells that do not appear to me - I tried to delete and re-add the segment. Everything was set up correctly. Trick....

The trick is to remove the following classes, cells, and sections from your subclass of UITableViewController. They are automatically added by Xcode, but if you use static cells, you do not 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 remove these methods, your cells will display correctly.

+18
source

Please make sure you select โ€œStatic Cellsโ€ in the content option in the table view.

Tableview

+4
source

I have a UITableViewController that has a view of a table with static cells

Are you sure your static table cells are in the UITableViewController and not inside the UITableView built into the UIViewController? Storyboard will allow you to add table cells to the table view built into the standard view controller, but this will not work at run time. Depending on the version of ios, you may or may not receive an error message. If the answer is yes, you need to add the cells of the static table directly to the user interface ** Table ** View ** Controller **.

+2
source

I had the same problem. If you have your own custom TableViewController, but the TableViewCell style is not set in normal mode, this happens. I walked around by changing the UITableViewController from my custom controller to a shared one. I assume that if the controller is normal, then we say that we will deliver the data programmatically, so the storyboard data is not presented. There must be far to get around this, but I'm too new to iOS to investigate. In addition, for prototyping, the overall UITableViewController works quite well. So: Go to the "Main table view controller" Select the identity inspector. Change class from your custom class to UITableViewController

Or use your custom controller, but change TableViewCell.Style to Custom in the Attributes Inspector

+2
source

Have you set dataSource and delegate for UITableViewController to self ?

0
source

I am facing the same problem these days. As already mentioned, Aryan, I have to add shortcut restrictions in the main view of the UISplitViewController . Otherwise, the content is not " disappear ", but on the left side of the table cell, that it does not correspond to the borders of the screen. Set for me the current field for viewing.

0
source

Prototyping in the Storyboard is all fine and dandy, but you still need to report the tableView property of the cells at runtime.

To do this, you need to specify each cell using reuseIdentifier:

enter image description here

Then you specify each reuse identifier explicitly in your code:

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 

Your problem is that you did not implement a dataSource that does exactly what it is called: delivers data.

Good luck.

-3
source

Source: https://habr.com/ru/post/973513/


All Articles