2016-12-20 111 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