【发布时间】:2014-02-03 03:32:43
【问题描述】:
我对如何解决这个问题感到有些不知所措,但我的搜索却一无所获。
我有以下代码:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
[_testTableView beginUpdates];
NSDictionary *dictionary = [_array00 objectAtIndex:fromIndexPath.section];
NSMutableArray *array = [dictionary objectForKey:@"data"];
NSString *itemToMove = [array objectAtIndex:fromIndexPath.row];
[array removeObjectAtIndex:fromIndexPath.row];
[array insertObject:itemToMove atIndex:toIndexPath.row];
[_testTableView moveSection:fromIndexPath.section toSection:toIndexPath.section];
//I need to know what size my array is at this point. _array00 is a NSMutableArray made up from 2 other NSMutableArrays.
[_testTableView endUpdates];
}
所以我正在制作一个应用程序,允许您将 cells 从一个 group 重新订购到另一个 UITableViewController。
我不确定我是否会这样说,但我希望它是有道理的。
当NSMutableArray 的大小发生变化时,我需要检查运行时,因为我将row 从一个section 移动到另一个。
有人可以帮帮我吗:-)
【问题讨论】:
-
何时在可变数组中添加或删除项目?你不控制吗?当项目改变时你能更新你的表吗?
-
是的,@AaronBrager 的意思是,你怎么能不知道,因为 你 是做出改变的人。
-
mmm 好的 - 不是我不知道,我的意思是就控制器而言要做什么来理解它,然后我想知道它是否在正确的位置应用程序的流量。 - 我会更新评论:-)
标签: ios objective-c cocoa-touch uitableview nsmutablearray