【发布时间】:2013-01-11 20:09:20
【问题描述】:
我有一个 UICollectionView,我在其中表示从 SQLite 数据库获取的数据。当我向上和向下滚动 CollectionView 时,我遇到了 UISwitch 问题:
-(UICollectionViewCell *)collectionView:(UICollectionView *)cv
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
city_setlist *cellValue = [self.arr objectAtIndex:indexPath.row];
UISwitch *onoff=(UISwitch *) [cell viewWithTag:106];
onoff.tag=[cellValue._id_setlist intValue];
if([cellValue._was_there isEqualToString:@"1"])
[onoff setOn:YES animated:YES];
else
[onoff setOn:NO animated:YES];
}
如果我不滚动,数据还可以,但如果我开始上下滚动 CollectionView,UISwitch 会随机打开它应该关闭的位置,反之亦然。我做错了什么?
【问题讨论】:
-
看来我们在这里遗漏了一些关键代码。你的
dequeueReusableCellWithIdentifier在哪里,而你正在返回cell,对吧?
标签: ios uicollectionview uiswitch