gpt4 book ai didi

ios:滚动后自定义单元格中的微调器消失

转载 作者:行者123 更新时间:2023-11-29 11:01:08 25 4
gpt4 key购买 nike

我创建了一个带有隐藏微调器和隐藏文本“加载更多”的自定义单元格。最后一个单元格的这些字段是未隐藏的,因此用户可以单击它来请求更多数据。我让它醒来,以便当用户单击最后一个单元格时微调器启动,但是当用户将单元格滚动到 View 之外并再次返回时,微调器不会显示。任何帮助将不胜感激。:)

我有一个自定义单元格,它是 UITableViewCell 的子类:

@interface BrowseListCell : UITableViewCell{
IBOutlet UIImageView *image;
IBOutlet UILabel *name;
IBOutlet UILabel *loadMore;
IBOutlet UIActivityIndicatorView *spinner;
}
@property(nonatomic, retain) UIImageView *image;
@property(nonatomic, retain) UILabel *name;
@property(nonatomic, retain) UILabel *loadMore;
@property(nonatomic, retain) UIActivityIndicatorView *spinner;
@end

在 tableViewController 中我有:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//#warning Incomplete method implementation.
// Return the number of rows in the section.
return [_dataController countOfList]+1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

// Configure the cell...
static NSString *CellIdentifier = @"BrowseListCell";

BrowseListCell *cell = (BrowseListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = [_cell autorelease];
_cell = nil;
}
if(indexPath.row==[_dataController countOfList]){
if (indexPath.row==0) {
cell.name.text=nil;
cell.image.image = nil;
cell.loadMore.hidden = YES;
return cell;
}else{
cell.name.text=nil;
cell.image.image = nil;
cell.loadMore.hidden = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
_spinner = [cell.spinner retain];
_loadCell = [cell retain];
return cell;
}
}
if(_dataController!=nil){
BrowseProduct *productAtIndex = [_dataController objectInListAtIndex:indexPath.row];

// Configure the cell...
if(productAtIndex!=nil){
cell.name.text = productAtIndex.name;
cell.image.image = productAtIndex.image;
cell.loadMore.hidden=YES;
}

}

return cell;

在 didSelectRowAtIndexPath 里面我有:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==[_dataController countOfList]){
if (indexPath.row==0) {
//do nothing
}else{
NSLog(@"Loading");
[_spinner startAnimating];
_loadCell.userInteractionEnabled = NO;
NSString *startFromId = [NSString stringWithFormat:@"%d", [_dataController countOfList]];
NSNotification *notification = [NSNotification notificationWithName:@"loadMore" object:startFromId];
[[NSNotificationCenter defaultCenter]postNotification:notification];
}
}
}

最佳答案

添加此代码,即使在停止动画后仍显示微调器

 spinner.hidesWhenStopped = NO;

请引用苹果链接UIActivityIndicatorView

关于ios:滚动后自定义单元格中的微调器消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15871070/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com