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


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;
链接地址: http://www.djcxy.com/p/87726.html

上一篇: UITableView不显示任何内容

下一篇: 表视图不显示数据,iphone