社区
iOS
帖子详情
reloadData方面问题,请大神帮忙看看
nicookly
2014-09-22 04:43:53
加精
didSelectRowAtIndexPath中调用一次[self.tableview reloadData] 后, 且 numberOfRowsInSection的返回值为1,却调用了两次cellForRowAtIndexPath,也创建了两次cell,且只显示一行(cell是用xib 实现的自定义cell)?????求解,急,大神如果知道,还请赐教。
...全文
1531
15
打赏
收藏
reloadData方面问题,请大神帮忙看看
didSelectRowAtIndexPath中调用一次[self.tableview reloadData] 后, 且 numberOfRowsInSection的返回值为1,却调用了两次cellForRowAtIndexPath,也创建了两次cell,且只显示一行(cell是用xib 实现的自定义cell)?????求解,急,大神如果知道,还请赐教。
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
15 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Java 狂魔
2014-09-28
打赏
举报
回复
很好,很有用,谢谢。
nettman
2014-09-24
打赏
举报
回复
CodeC
2014-09-24
打赏
举报
回复
为什么就不给一个机会,自己强大才能保护他人
程老师2088
2014-09-23
打赏
举报
回复
应该是有别的地方重复调用了。。楼主仔细检查下
laoer_2002
2014-09-23
打赏
举报
回复
还是要好好学习
wanruochuwenyy
2014-09-23
打赏
举报
回复
好高端的样子啊 完全不懂啊
hugh_z
2014-09-23
打赏
举报
回复
learning
ReyZhang
2014-09-23
打赏
举报
回复
断点看一下numberOfRowsInSection 这个代理方法执行几次?如果也执行了两次,可以确定重载了两次数据。还是仔细检查一下。
Bannings
2014-09-22
打赏
举报
回复
你在cellForRowAtIndexPath方法里下断点,能看到两次调用的时机么
nicookly
2014-09-22
打赏
举报
回复
引用 1 楼 zhangao0086 的回复:
是不是在其他的地方也有调用的代码?或者tableView有几个实例?
我也只是 触发单击事件里 调用了 reloadData 而且是在viewDidLoad 中创建的tableView。
nicookly
2014-09-22
打赏
举报
回复
引用 2 楼 hantianjie_ 的回复:
代码贴出来看看
代码 已贴出
nicookly
2014-09-22
打赏
举报
回复
只在viewDidLoad中创建了一个 tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 110,[UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height - 110) style:UITableViewStylePlain]; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *TableSampleIdentifier = @"TableSampleIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableSampleIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableSampleIdentifier]; //在添加cell时添加边线框 UIView *backView = [[UIView alloc] initWithFrame:cell.frame]; backView.layer.masksToBounds = YES; backView.layer.cornerRadius = 1.0; backView.layer.borderWidth = 1.0; backView.layer.borderColor = [[UIColor lightGrayColor] CGColor]; [cell addSubview:backView]; } if (_chapterList.count == 2) { NSLog(@"sdasdasdsdasd111111111111"); } NSUInteger row = [indexPath row]; cell.textLabel.text = [[_chapterList objectAtIndex:row]objectForKey:@"type_name"]; return cell; } ================= - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; //这部分解析xml 的 self startParseQuestion:[[_chapterList objectAtIndex:row] objectForKey:@"id"] ]; [_questionList removeAllObjects]; // 将解析到的数据放入_questionList中 [_questionList addObjectsFromArray:[myPlayer questionDataArray]]; if (_questionList.count == 0) { UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该部分内容正加紧录制中,敬请期待!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alter show]; } else { [self.tableview reloadData]; } } ============ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (isQuestion != NO) { NSLog(@"_questionList.count::::%d",_questionList.count); return _questionList.count; } else { NSLog(@"_chapterList.count::::::%d",_chapterList.count); return _chapterList.count; } }
hantianjie_
2014-09-22
打赏
举报
回复
代码贴出来看看
Bannings
2014-09-22
打赏
举报
回复
是不是在其他的地方也有调用的代码?或者tableView有几个实例?
详解ios监听
reload
Data
刷新列表完毕的时机
主要介绍了详解ios监听
reload
Data
刷新列表完毕的时机,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来
看看
吧
关于UICollectionView横向滑动分页的
问题
在iOS开发中,UICollectionView是一种非常强大的视图组件,它允许我们以网格布局展示大量数据,同时支持自定义布局,使得用户界面...
请
确保仔细阅读和分析代码,以便深入理解UICollectionView的工作方式和潜在
问题
。
iOS上拉加载更多的实现
在
请
求完成时,更新数据源数组并调用`
reload
Data
`刷新表格。 7. **处理下拉刷新** 如果你也需要实现下拉刷新功能,可以使用UIRefreshControl。在`viewDidLoad`中添加一个UIRefreshControl实例,并在`...
IOS下拉刷新Demo实现
[self.tableView
reload
Data
]; [self.pullRefreshView endRefreshing]; }); } ``` 3. **自定义下拉刷新视图** - 如果你想支持中英文显示,可以修改EGOTableViewPullRefresh的本地化字符串。 - 在项目中创建...
UICollectionView Demo
6. **加载数据**:在`viewDidLoad`或适当的地方,通过调用`
reload
Data
`来加载数据源并刷新界面。 7. **单元格复用**:为了提高性能,`UICollectionView`使用了类似`UITableView`的复用机制。每次显示新的单元格时,...
iOS
29,049
社区成员
12,464
社区内容
发帖
与我相关
我的任务
iOS
主要讨论与iOS相关的软件和技术
复制链接
扫一扫
分享
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章