2016-12-20 70 views
1
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    [tableView beginUpdates]; // tell the table you're about to start making changes 

    if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { 
     self.expandedIndexPath = nil; 
    } else { 
     self.expandedIndexPath = indexPath; 
    } 


[tableView endUpdates]; // tell the table you're done making your changes 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { 
     return 200.0; // Expanded height 
    } 
    return 44.0; // Normal height 

}扩展表格单元格上单击目标C

- (void)pieChart:(XYPieChart *)pieChart didSelectSliceAtIndex:(NSUInteger)index 
{ 
    This is a function of getting the index , when clicking a pie chart. 
    what i need to do is expand the corresponding row of table when pie is selected 
} 

@end 
+0

请提供一些外面的按钮代码或逻辑你已经尝试过 – Arun

回答

1

如果我有你的想法,你需要在指数路径选择行

- (void)pieChart:(XYPieChart *)pieChart didSelectSliceAtIndex:(NSUInteger)index 
{ 
    // get indexPath with index 
    // remember if you have few sections then you will need to update inSection:0 value 
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0]; 

    [yourTableView selectRowAtIndexPath:indexPath 
           animated:NO 
         scrollPosition:UITableViewScrollPositionNone]; 

    // This will also Highlighted the row. Then delegate 
    [yourTableView.delegate someTableView didSelectRowAtIndexPath:indexPath]; 
} 
+0

我不能在pieChart函数中调用我的表函数。“yourtableView”显示错误(我给出了我的表名本身) –

+0

如何扩展对应的正确单元格对饼图 –

+1

中选定的片断的访问停止...如果您调用表视图,则需要将表视图实现为弱属性。但要正确显示完整的代码 – Nazir