Content in UITableViewCell not showing

I'm having issues with UITableViewCell .

I have a view manager in my storyboard that is connected to my view controller named MainViewController . It contains a UITableViewCell with three shortcuts. UITableViewCell connected to the MTTableViewCell class.

 // MTTableViewCell.h #import <UIKit/UIKit.h> @interface MTTableViewCell : UITableViewCell @property (strong, nonatomic) IBOutlet UILabel *mainLabel; @property (strong, nonatomic) IBOutlet UILabel *statusLabel; @end // MTTableViewCell.m #import "MTTableViewCell.h" @implementation MTTableViewCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end // MainViewController.m -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; MTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[MTTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } NSString *namecell = @"namecell"; NSString *statuscell = @"statuscell"; [cell.mainLabel setText:namecell]; [cell.statusLabel setText:statuscell]; return cell; } 

The problem is that when MainViewController starts MainViewController nothing is displayed. What am I missing? I don't get any arrangements, just an empty table with 1 empty entry.

+7
ios objective-c uitableview
source share
10 answers

Look into your interface designer - you have not created your “connected” user cell, you must set it as the “file owner”, since you have implemented the view, you do not want to set the delegate. Maybe this hint helps?

+2
source share

You are not loading a cell from the main package: Use the code below that will work for you:

 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *simpleTableIdentifier = @"FleetAccountCell"; FleetAccountCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"FleetAccountCell" owner:nil options:nil] objectAtIndex: 0];; } return cell; } 
+2
source share

Try to find here ... the answer to your problem may be

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object{ CustomCell *cell = (CustomCell * )[self.tableView dequeueReusableCellWithIdentifier:@"YOUR CELL NAME" forIndexPath:indexPath]; // your content cell... return cell; } 

Read here PFQueryTableViewController not displaying custom cells

Greetings :)

+1
source share

This work is for me ..

 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *simpleTableIdentifier = @"cellID"; FleetAccountCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"Your_nibName" owner:nil options:nil] objectAtIndex: 0]; } [cell layoutIfNeeded]; return cell; } 
+1
source share

Declare TableViewcell this way

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

Below me did not work

TableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: @ "Cell"];

+1
source share

You did not instantiate mainLabel and statusLabel, so now they are zero. They must be created in the initWithStyle method.

0
source share

Rewrite the cellForRowAtIndexPath: method as shown below

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; MTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"CUSTOME_CELL_Nib_NAME" owner:nil options:nil] objectAtIndex: 0];; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } NSString *namecell = @"namecell"; NSString *statuscell = @"statuscell"; [cell.mainLabel setText:namecell]; [cell.statusLabel setText:statuscell]; return cell; } 
0
source share
 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 4; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"cell"; TableViewCell *cell = (TableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell==nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; } return cell; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } 
0
source share

I had the same problem: I did not have a connection in the tableview and datasource delegates:

 self.yourtableviewname.delegate=self; self.youtableviewname.datasource=self; 

After that, it worked fine.

0
source share

Select a cell and on the inspector tab mark “installed” and it will work.

0
source share

All Articles