I have a subclass of uiviewcontroller,and implemented the delegate UITableViewDelegate and UITableViewDataSource.my code like:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
_listname=[[NSMutableArray alloc]initWithObjects:@"cu",@"al",@"zn",@"au",@"ru",@"fu",@"rb",@"pb",@"wr", nil];
}
- (void)dealloc
{
[super dealloc];
}
#pragma mark -
#pragma mark Table View Source Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
[tableView setSeparatorColor:[UIColor clearColor]];
return [_listName count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return TABLE_HEIGHT;
}
I have set the breakpoints,and the delegate method is never called.what’s the problem?
You need to set the tableView delegate and data source to self
and implement the method (returning at least 1)