2014-05-22 29 views
0

所以我试图使单元格的图像视图跟随该单元格的拖放,我使用this control: BVReorderTableView来启用重新排序单元格而无需编辑模式。 (我已经通过电子邮件向开发者了解了我的问题)使cell.imageviews遵循单元格的重新排序[已解决]

我的表视图的单元格内的文本对重新排序没有问题,但这些单元格的图像视图不遵循。

我愿意尝试任何其他控制你建议重新排序单元格,或自己做(但我是一个初学者)。

代码:

- (id)saveObjectAndInsertBlankRowAtIndexPath:(NSIndexPath *)indexPath { 
    id object = [self.ArrayofFiveFriends objectAtIndex:indexPath.row]; 
    [self.ArrayofFiveFriends replaceObjectAtIndex:indexPath.row withObject:@""]; 
    return object; 
    } 

- (void)moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 
    id object = [self.ArrayofFiveFriends objectAtIndex:fromIndexPath.row]; 
[self.ArrayofFiveFriends removeObjectAtIndex:fromIndexPath.row]; 
[self.ArrayofFiveFriends insertObject:object atIndex:toIndexPath.row]; 
} 

- (void)finishReorderingWithObject:(id)object atIndexPath:(NSIndexPath *)indexPath; { 
[self.ArrayofFiveFriends replaceObjectAtIndex:indexPath.row withObject:object]; 
} 

编辑:已解决的问题,看到了自己的答案

+0

你能给我们提供你设置单元格的代码吗? (可能是cellForRowAtIndexpath方法) – Kujey

+0

当然,这里是 http://pastebin.com/E7hMagJF –

回答

0

好它似乎很简单。在你的代码中,你这样做了:

NSString *friendID = [self.ArrayofFriendsID objectAtIndex:indexPath.row]; 
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", friendID]]; 
NSData *data = [NSData dataWithContentsOfURL:url]; 
UIImage *image = [UIImage imageWithData:data]; 
cell.imageView.image = image; 

你可以看到你的单元格图像是基于存储在self.ArrayofFriendsID中的数据的。然而,当你重新排序你的单元格时,你只能更新self.ArrayOfFiveFriends。 (请参阅您的文章中的代码)。这就是为什么你的图片不会遵循。

+0

我的问题是BVReorderTableView的工作方式我只能更新一个列表ArrayofFiveFriends(其中包含这些朋友的名字)。 我可以使用原始文章的BVReorderTableView的函数返回多个值吗? (这样我可以更新名称和图片),还是我需要手动更改BVReorderTable的类来处理多个参数? 主要问题是如何在这些函数中处理mytableview的单元格。我会尝试另一个控制,我发现像[这一个](https://github.com/jamztang/JTGestureBasedTableViewDemo) –

+0

与JTGestureBasedTableView相同的问题 –

+0

而不是有两个数组,你可以尝试创建一个字典元素的数组? 字典看起来像这样: @ {@“friendID”:friendID,@“friendObject”:friendObject} – Kujey

0

我做到了!

我用这个tutorial

我的伟大工程的图像跟随文字(其实你只是默认设置编辑模式和隐藏每一个编辑元素+一些自定义)

感谢Kujey试图帮助我!

相关问题