每次用户双击我的手机时,我都会尝试展示标签。我可以检测到水龙头,我可以从它们执行代码,但我遇到标签问题。出于某种原因,标签被添加两个,有时三个单元格应该添加到标签之下。我需要在被敲击的单元格上添加标签,不应该很难做到。
这是我的代码,提前谢谢。
[
{
"name": "1st Online Soultions"
"label": "01-02",
"count": "577",
"customerid": "129"
},
{
"name": "Bookngo"
"label": "01-020",
"count": "2",
"customerid": "129"
},
{
"name": "Boutixury"
"label": "07",
"count": "1",
"customerid": "14"
},
{
"name": "Cruise Village"
"label": "07",
"count": "16",
"customerid": "25"
},
.................
]
答案 0 :(得分:2)
您不应该使用didSelectRowAtIndexPath
方法对单元格进行双击。
Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (nil == cell)
{
cell = [[Cell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
而是使用-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
检索选定索引路径的单元格,如下所示。
Cell *cell = [tableView cellForRowAtIndexPath:indexPath];
如果需要,您可以在didSelectRowAtIndexPath
方法的末尾调用以下方法。
[tableView reloadRowsAtIndexPaths: [NSArray arrayWithObject: indexPath]
withRowAnimation: UITableViewRowAnimationNone];