簡體   English   中英

如何從 UITABLEVIEW 中刪除一行並將其插入到 iphone 的第二個 UITABLEVIEW 中?

[英]How to delete a row from an UITABLEVIEW and insert it in a second UITABLEVIEW in iphone?

我在 iphone 中開發了一個管理卡片的程序,主要功能是創建卡片(問題、答案)並在 uitableview 中顯示它們(到目前為止工作正常)。 每張卡片都有兩個按鈕,即:ok-false,我的想法是當用戶點擊ok按鈕時,這張卡片會出現在一個新的uitableview2中,並從uitableview1中刪除(我不知道該怎么做)。 預先我在 sqlite 中的卡表中添加了一個新屬性,即計數器,只要用戶單擊確定,它就會增加,其背后的想法是,當計數器增加時,將執行我需要的 function“從當前 Z10E5932C6Z3597A 中刪除並插入” in new uitableview" 如果用戶點擊 false,則卡片將從 tableview2 中刪除並插入 tableview1。 我會感謝任何想法的人。

謝謝!

只需在點擊確定時從表 1 中刪除該行,然后在表 2 中添加一行。嘗試類似的操作 -

[self.tableView beginUpdates];
[self.list removeObjectAtIndex:index]; //index of the row on which ok was tapped
[self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation: UITableViewRowAnimationNone]; //indexPaths is an array with a single NSIndexPath that corresponds to index
[self.tableView endUpdates];

現在將同一行添加到表 2-

[self.list2 insertObject:card atIndex:0]; //card is the same card that was deleted from table 1
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
NSArray* arr = [[NSArray alloc] initWithObjects:indexPath, nil];
[self.tableView insertRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationNone];
[arr release];

高溫下,

阿克謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM