【发布时间】:2016-07-05 10:27:14
【问题描述】:
我有一个表格视图,并且我使用了两个自定义单元格。在自定义单元格中,我设置了一个 uilabel 并隐藏。现在,当用户从表格视图中选择一个单元格时,在 didSelectRowAtIndexPath 方法中,我想显示该标签。我尝试了跟随,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
HoteldetalcelloneTableViewCell *cellone = [tableView dequeueReusableCellWithIdentifier:@"cellone"];
HoteldetailcelltwoTableViewCell *celltwo = [tableView dequeueReusableCellWithIdentifier:@"celltwo"];
if(indexPath.section == 0)
{
HotelDetailsone *secone = [roomonearray objectAtIndex:indexPath.row];
if([secone.offerallow isEqualToString:@"True"])
{
celltwo.selectedsignLabel.hidden = NO;
}
else
{
cellone.selectedsignLabelone.hidden = NO;
}
NSLog(@"price for room 1 : %@", secone.itempriceText);
}
else
{
HotelDetailsone *sectwo = [roomtwoarray objectAtIndex:indexPath.row];
NSLog(@"price for room 2 : %@", sectwo.itempriceText);
}
}
注意:我使用了断点并检查过,它通过正确的语句导航。但没有任何反应
我也试过了,
[cellone.selectedsignLabelone setHidden:NO];
但什么都没有发生。希望你能帮助 this.thanx。
【问题讨论】:
-
您确认标签存在了吗?他们有一个非零大小?他们有任何文字吗?
-
是的,只有“✓”号可用。
-
不要在
cellForRowAtIndexPath之外操作视图(表格视图单元格)。在模型中添加属性selected(数据源数组中项的类型),在cellForRow...中处理并重新加载表格视图。 -
你这里有多少个部分?
-
多选
标签: ios objective-c uitableview hidden didselectrowatindexpath