2012-04-20 46 views
1

我怎樣才能找出我點擊哪個部分?我需要的號碼發送到另一個視圖的項目:如何獲取選定的自定義TableViewCell的節號?

- (IBAction)mapButton:(id)sender { 

    UIButton * myButton = sender; 
    int row=myButton.tag; 

    NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row inSection:0]; 

    MapViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"mapView"]; 

    self.selectedStandort = [self.fetchedResultsController objectAtIndexPath:indexPath]; 



    detail.currentStandort = self.selectedStandort; 

    [self.navigationController pushViewController:detail animated:YES]; 


} 

回答

2

是mapButton UITableViewCell的子視圖? 然後我會做到以下幾點:

​​

您也可以使用該行從cellIndexPath,所以你不必讓您的標記值高達日期(例如上重用,重新排序和刪除),這使得你的實現不太容易出錯。

+0

我的mapButton在自定義tableviewcell中,我給了他一個標籤。你的解決方案沒有奏效,你能否給我另一個解決方案? – 2012-04-20 10:12:00

+0

我忘了該按鈕在UITableViews contentView中。 因此,該單元是[[發件人超級查看]超級查看]來代替。 我編輯了我的答案以反映這種變化。 – Thyraz 2012-04-20 10:18:38

+0

它的作品非常感謝你 – 2012-04-20 10:23:15