2014-05-22 71 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試圖幫助我!

相關問題