ios - 在用户定义的函数中更改单元格的附件 View

标签 ios uitableview tableview

我想更改单元格的附属 View 。当用户单击右侧导航栏项时,会发生一个 Action ,在该 Action 中我想更改附件 View 。我该怎么做,当我使用这段代码时,它要求 NSindexPath 东西,所以我不知道我可以在这里给出哪个值,以更改所有单元格的 View 。

 MyCustomCell *cell = (MyCustomCell *) [self.tableView cellForRowAtIndexPath:helloIndexPath];
    if( cell.accessoryType ==  UITableViewCellAccessoryDisclosureIndicator)
    {
        cell.accessoryView = [[UIImageView alloc]initwithImage:[UIImage imageNamed:@"hello.png"]];
    }

最佳答案

我猜你应该把条件放在 TableView 中 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

在这里你可以放一个if -条件。

if(flagForAction){
cell.accessoryView = [[UIImageView alloc]initwithImage:[UIImage imageNamed:@"hello.png"]];
}
else
{
cell.accessoryView = [[UIImageView alloc]initwithImage:[UIImage imageNamed:@"<no-Hello>.png"]];
}

您需要做的就是设置标志并重新加载表格。调用[<your table> reloadData];

关于ios - 在用户定义的函数中更改单元格的附件 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23949044/

相关文章:

ios - 自动滚动到具有特定值的单元格

ios - 为 UITableView 提取 HTML 表格

IOS View如何让它透明完全消失

ios - 如何添加包含新数据的临时单元格?

iphone - 如何将导航 Controller 添加到翻转 View ?

ios - Alpha 在 UITableViewCell 中不起作用

iphone - 让 iOS 签名的应用程序在越狱设备上执行未签名的应用程序

ios - 代码和设计的一个本地化源

swift - 如何更改整个应用程序的 UITableView 的颜色?

html - 移动 safari 图片上传及其大小