views:

33

answers:

3

hello all,

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.

A: 

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?

Ben Gottlieb
yes the method - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [m_CurrShop.m_SalesList count];}get called and return 3.
Amir
And the numberOfSectionsInTable: returns what?
Kalle
A: 

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.

Leg10n
A: 

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*)];
bstahlhood