每次索引的索引都是0里面:
- (UIView *)swipeView:(SwipeView *)swipeView viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
view = [[MTResultCard alloc] initWithFrame:_swipeView.frame];
NSDictionary *resultsDictionary = [[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"];
NSString *key = [[[[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"] allKeysSorted] objectAtIndex:index];
((MTResultCard *)view).item = [[[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"] objectForKey:key];
return view;
}
-(NSArray *)allKeysSorted{
return [[self allKeys]sortedArrayUsingComparator:^NSComparisonResult(NSString* obj1, NSString* obj2) {
return [obj1 compare:obj2];
}];
}
完整代码可以在这里查看
每次我有 index = 0 的原因是什么?