Reputation: 455
I build UIView with few labels and one UITableview
. the problem is that when I load the view the method - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
never get called.
the code:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
m_ShopSalesTable =[[UITableView alloc]init]; //this is the UITableView
m_ShopSalesTable.delegate = self;
m_ShopSalesTable.dataSource = self;
[self.view addSubview:m_ShopSalesTable];
[m_ShopSalesTable reloadData];
}
i have put the UITableViewDelegate
,UITableViewDataSource
> in the declaration of the class
but nothing helped.
Upvotes: 1
Views: 743
Reputation: 119242
As Kalle has asked in a comment on another answer, what are you returning from your numberOfSections method? In the default created from the template, I think this returns zero which has bitten me on a few occasions.
Upvotes: 0
Reputation: 11
I had the same issue where cellForRowAtIndexPath was never called. I had several issues:
Spent about 5 hours trying to figure this out, hope it helps someone else!
Upvotes: 1
Reputation: 2006
You are initializing with no frame. You are doing this:
[[UITableView alloc]init];
I would do this:
[[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, *setYourWidthHere*, *setYourHeightHere*)];
Upvotes: 1
Reputation: 552
I don't see where you assign tableview to m_shopSales Try:
self.tableView=m_ShopSalesTable;
before reloadData
Also m_ShopSalesTable is leaking do a release after setting self.tableView.
Upvotes: 0
Reputation: 85522
Did you set the tableView datasource to be the class that implements the above method? Did you return a non-zero number for both -numberOfSectionsInTableView: and –tableView:numberOfRowsInSection:? Are ANY of your tableview datasource methods being called?
Upvotes: 0