gpt4 book ai didi

iphone - 注册 tableView 使用 willDisplayCell 完成加载 - 不适用于 0 个结果

转载 作者:行者123 更新时间:2023-11-28 22:38:30 24 4
gpt4 key购买 nike

如果我的 tableView 没有可显示的内容,我需要提醒用户有 0 个结果。我在我的 willDisplayCell 方法中这样做,但如果有 0 个结果,它不会注册。有谁知道如何修改这个?谢谢!

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell 
forRowAtIndexPath:(NSIndexPath *)indexPath {

if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows]
lastObject]).row) {

if ([self.listItems count] == 0) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Results" message:@"No
results found" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
}

最佳答案

您可以在您的 viewWillAppear 方法中显示警报 您的 willDisplayCell 方法未被调用,因为您的行数为 0,并且如果您仔细查看您的 willDisplayCell 方法你会发现一个参数 forRowAtIndexPath,这就是为什么它没有被调用,因为行数为零。

-(void)viewWillAppear:(BOOL)animated
{

if ([self.listItems count] == 0)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Results" message:@"No
results found" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
else
{
[tableView reloadData];
}
[super viewWillAppear:animated];
}

关于iphone - 注册 tableView 使用 willDisplayCell 完成加载 - 不适用于 0 个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15218245/

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