开发者

uitabview delegate method never called

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=[[NSMutableAr开发者_如何学Goray 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

tableView.delegate = self;
tableView.dataSource = self;

and implement the method (returning at least 1)

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜