three20 用more button 分页,自动加载更多行

参考原文:http://code.coneybeare.net/three20-how-to-autoload-more-results-when-you

 

下面的我的代码

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)tableViewDidLoadModel:(UITableView*)tableView {
    
    NSMutableArray* items = [[NSMutableArray alloc] init];
    for (TSBazaarInfo* post in _searchFeedModel.posts) {
        
        [items addObject:
         [TSBazaarListItem itemWithTitle:post.title caption:[NSString stringWithFormat:@"%@ | %@ | Post by %@",post.area_name,[post.created formatRelativeTime],post.username]
                                text:post.content price:post.pricetext contentid:post.contentid imageURL:post.icon URL: [NSString stringWithFormat:@"tt://bazaar/getone/%d",post.contentid]]];
    }
    
    if(!([items count]%10))[items addObject:[TTTableMoreButton itemWithText:@"More"]];
    self.items = items;
    TT_RELEASE_SAFELY(items);
}

- (void)tableView:(UITableView*)tableView cell:(UITableViewCell*)cell willAppearAtIndexPath:(NSIndexPath*)indexPath {
    [super tableView:tableView cell:cell willAppearAtIndexPath:indexPath];
    if (indexPath.row == self.items.count-1 && [cell isKindOfClass:[TTTableMoreButtonCell class]]) {
        TTTableMoreButton* moreLink = [(TTTableMoreButtonCell *)cell object];
        moreLink.isLoading = YES;
        [(TTTableMoreButtonCell *)cell setAnimating:YES];
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        [self.model load:TTURLRequestCachePolicyDefault more:YES];
    }
}
posted @ 2012-05-20 12:02  alex hu  阅读(427)  评论(0编辑  收藏  举报