Iphone &引用;加载更多…”;在带有自定义单元格的tableView上-单元格重用给我带来了一些问题
我试图在tableView上实现“加载更多…”。我做过,但不知道是否有效。 问题是我有自定义单元格,如果我喜欢这样做:Iphone &引用;加载更多…”;在带有自定义单元格的tableView上-单元格重用给我带来了一些问题,iphone,ios,xcode,cocoa-touch,uitableview,Iphone,Ios,Xcode,Cocoa Touch,Uitableview,我试图在tableView上实现“加载更多…”。我做过,但不知道是否有效。 问题是我有自定义单元格,如果我喜欢这样做: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Cell"; ArticlesCell *cell = [tableView de
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
ArticlesCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ArticlesCell" owner:self options:NULL];
cell = (ArticlesCell *) [nib objectAtIndex:0];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
tableView.backgroundColor = cell.backgroundColor;
if (indexPath.row <= (self.bookmarks.count - 1)) {
[self configureCell:cell atIndexPath:indexPath];
}else{
cell.textLabel.text = @"Load more...";
}
return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*cellIdentifier=@“Cell”;
ArticlesCell*单元格=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
如果(单元格==nil)
{
NSArray*nib=[[NSBundle mainBundle]loadNibNamed:@“ArticlesCell”所有者:自选项:NULL];
单元格=(ArticlesCell*)[nib对象索引:0];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
tableView.backgroundColor=cell.backgroundColor;
如果(indexPath.row当您单击loadmore按钮时,请增加行数并重新加载tableview。即,在方法numberofrowsinsection中。当您单击loadmore按钮时,请告诉我您是否需要更多的行数并重新加载tableview。即,在方法numberofrowsinsection中。让我知道如果您还需要更多的另一种方法是使用两个不同的单元格标识符,一个用于标识和重用(初始创建后)ArticleCell,另一个用于标识和重用(初始创建后)一个“加载更多…”UITableViewCell。至少您将只创建“加载更多…”UITableViewCell一次,而不是每次滚动到视图中
static NSString *ArticleCellIdentifier = @"ArticleCell";
static NSString *LoadMoreCellIdentifier = @"LoadMoreCell";
Apple iOS示例项目使用了类似的方法(请参阅Classes/RootViewController.m)。另一种方法是使用两个不同的单元标识符,一个用于标识和重用(初始创建后)ArticlesCell,另一个用于标识和重用(初始创建后)一个“加载更多…”UITableViewCell。至少这样,您将只创建一次“加载更多…”UITableViewCell,而不是每次滚动到视图中
static NSString *ArticleCellIdentifier = @"ArticleCell";
static NSString *LoadMoreCellIdentifier = @"LoadMoreCell";
Apple iOS示例项目使用了类似的方法(请参阅Classes/RootViewController.m)。这就是我所做的。确实如此。它工作得很好,我关心的是我是否以一种良好的编程方式显示“Load more…”单元格?这就是我所做的。确实如此。它工作得很好,我关心的是我是否显示了“Load more…”以一种良好的编程方式计算单元?