Core data 自定义UITableViewCells滚动时为空
我有两个自定义的Core data 自定义UITableViewCells滚动时为空,core-data,uitableview,ios7,magicalrecord,afnetworking-2,Core Data,Uitableview,Ios7,Magicalrecord,Afnetworking 2,我有两个自定义的UITableViewCells我试图使用MagicalRecord从CoreData提取的数组中填充。显示前三行数据(视图加载时最初可见的单元格),但当我滚动时,下面的单元格中没有填充任何数据。此外,当我向上滚动时,最初显示数据的单元格现在为空。因此,当任何细胞被重用时,这种情况似乎都会发生。我一直在绞尽脑汁,想尽办法解决这个问题,结果一无所获。这是我的cellforrowatinexpathcode - (UITableViewCell *)tableView:(UITabl
UITableViewCells
我试图使用MagicalRecord
从CoreData
提取的数组中填充。显示前三行数据(视图加载时最初可见的单元格),但当我滚动时,下面的单元格中没有填充任何数据。此外,当我向上滚动时,最初显示数据的单元格现在为空。因此,当任何细胞被重用时,这种情况似乎都会发生。我一直在绞尽脑汁,想尽办法解决这个问题,结果一无所获。这是我的cellforrowatinexpath
code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Explore *explore = [self.exploreCellData objectAtIndex:[indexPath row]];
if ([explore.belief_id isEqualToString:@"0"]) {
ExploreVoteCell *cell = (ExploreVoteCell *) [tableView dequeueReusableCellWithIdentifier:@"ExploreVote" forIndexPath:indexPath];
[cell.topicTitle setText:[explore topic_title]];
[cell.votesCount setText:[explore calc_totalVotes]];
[cell.timeDayCount setText:[explore day_difference]];
return cell;
} else {
ExploreBeliefCell *cell = (ExploreBeliefCell *) [tableView dequeueReusableCellWithIdentifier:@"ExploreBelief" forIndexPath:indexPath];
[cell.topicTitle setText:[explore topic_title]];
return cell;
}}
当我计算数组中的记录数(行数)或NSLog
表视图加载数据时,一些数据元素就在那里。但是,当我滚动NSLog
时,我在'CellForRowatinedexPath'内设置的方法在滚动需要开始重用单元格时开始返回空值
我对使用MagicalRecords
和AFNetworking
都是新手,所以我可能没有正确地处理它们。下面是我如何将CoreData中的数据拉入我的NSMutableArray
- (void) fetchData {
self.exploreCellData = [NSMutableArray arrayWithArray:[Explore MR_findAllSortedBy:@"calc_totalVotes" ascending:YES]];}
非常感谢您的帮助 尝试使用:[tableView注册表类:[YOURCUSTOMCELL类]forCellReuseIdentifier:@“CUSTOMIDENTIFIER”] 例如,在viewDidLoad中 在cellForRowAtIndexPath中:
-(UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"CUSTOMIDENTIFIER"];
return cell
}
我已经在上面输入的CellForRowAtIndexPath代码中运行了该代码。。。还有其他想法吗?