How to reference tableView from a view controller during a segue

前端 未结 4 615
旧时难觅i
旧时难觅i 2020-12-15 11:35

I\'m new to iOS development, so go easy on me please :)

Using Xcode 4.2 for iOS 5, I\'ve built a view controller in IB, with a tableview inside it linked to a detail

4条回答
  •  旧时难觅i
    2020-12-15 12:08

    I'm also new to iOS, but for what it's worth:

    Sounds like you need to create a pointer to your table view object in your UIViewControllerClass.

    @interface YourClass : UIViewController
    {
        IBOutlet UITableView  *MyTableView;
    }
    @property ... IBOutlet UITableView *MyTableView;
    

    ...and then hook this up to your "table view" within IB. Such that in prepareForSegue you can then access the UITableView object.

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        NSIndexPath *selectedIndexPath = [self.MyTableView indexPathForSelectedRow];
        ...
    }
    

提交回复
热议问题