tranvutuan
tranvutuan

Reputation: 6109

table view does not display data,iphone

I am working with UITableView now and what I an having is

MyClass.h

@interface MyClass : UIViewController {

}

@property (strong , strong) UILabel *name;

@property (strong , strong) UILabel *add;

and

MyClass.m

-(NSInteger)tableView:(UITableView *)atableView numberOfRowsInSection:(NSInteger)section{

return 3 ;
 }

-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"cell";
tableCell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
...................................................

return tableCell; 

}

When I put i break point at numberOfRowsInSection, it seems that it is not being executed at all. It is confusing me now. Please advice if you have encountered it before.

Thanks

Upvotes: 2

Views: 1466

Answers (1)

danh
danh

Reputation: 62686

The most common cause of this is not setting your view controller as the table view delegate and datasource. If it's built in storyboard, you can do this by selecting the connections inspector on the table and dragging those properties to the view controller.

Otherwise, set it in code like this:

self.tableView.delegate = self;
self.tableView.datasource = self;

Upvotes: 3

Related Questions