UITableView不显示数据

来源:互联网 发布:python socket编程 编辑:程序博客网 时间:2024/05/07 17:23

原因:自定义的viewcontroller不是继承自uitableviewcontroller的,而是<UITableViewDelegate,UITableviewDataSource>,

所以在.m文件中需设置:   tableview.delegate = self;

tableview.dataSource = self;(especially  this line)


因为- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

和- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

是protocol UITableViewDataSource 的方法。


原创粉丝点击