我们不会谈论数千行或任何事情,但如果有办法让事情扩大到那么高,我会喜欢它.
我有一个包含27个部分和180行遍布所有部分的表格,而我现在陷入困境的情景是当我将事物设置为只有3个部分和5个行的模型状态时,以及(甚至更糟)再次返回.
我正在使用beginUpdates/endUpdates对所有动画进行批处理.我的应用程序很好地锁定了iphone4上的1-2秒,同时它解决了问题,然后动画开始.
我已经尝试了动画删除/添加每一行,保持周围的部分(并在删除情况下将它们的行数减少到0),并且还动画只是删除/插入部分本身(当行计数时已降至0).我会假设后者会提供更好的表现,但它根本没有改变.
有没有什么可以在应用程序端完成加快这一点?现在,如果有超过20个动画,我会有相当多的代码来摆脱单个动画,而选择仅重新加载数据.
编辑这里显示问题的代码.这段代码的性能略好于等效的monotouch代码(这是我之前使用的),但它仍然非常糟糕.
#import "TableViewController.h"
@interface MyTableViewDataSource : NSObject<UITableViewDataSource> {
int rows;
};
@end
@implementation MyTableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (void)setRowCount:(int)r
{
rows = r;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return rows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.text = [NSString stringWithFormat:@"row %d", indexPath.row];
return cell;
}
@end
@implementation MyTableViewController { …Run Code Online (Sandbox Code Playgroud) 我正在编写一个IL静态分析工具,我很难理解控制泛型类型参数的规则:
拿这个IL(来自IList<T>界面):
.property instance !T Item(
int32 index
)
{
.get instance !0 System.Collections.Generic.IList`1::get_Item(int32)
.set instance void System.Collections.Generic.IList`1::set_Item(int32, !0)
}
Run Code Online (Sandbox Code Playgroud)
为什么!0那里而不是!T?我认为就VM而言,它们是等效的,当你保证拥有这些名字时,使用位置引用似乎很奇怪.
更新:来自KeyedCollection.ctor的另一个案例:
IL_0037: newobj instance void class System.Collections.Generic.Dictionary`2<!TKey,!TItem>::'.ctor'(class System.Collections.Generic.IEqualityComparer`1<!0>)
IL_003c: stfld class System.Collections.Generic.Dictionary`2<!0,!1> class System.Collections.ObjectModel.KeyedCollection`2<!0,!1>::dictionary
Run Code Online (Sandbox Code Playgroud)