我想更改单元格的附属 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/