2

所以我将didSelectRowAtIndexPath方法放入UITableViewController

TableView 转到由NavigationController控制的UIViewController

我想将 indexPath.row 发送到 NavigationController 调用的类,有没有办法将参数发送到另一个类

我的应用方案是:

TabBarController ---> NavigationController ---> TableViewController ---> UIViewController

4

1 回答 1

0

如果您使用情节提要:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UITableViewCell *cell = sender;
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];
        NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];

        // Pass any objects to the view controller here, like...
        [vc setIndexPath:indexPath];
    }
}

别的

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        YourViewController *vc = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
        [vc setIndexPath:indexPath];
    }

}
于 2012-09-01T18:51:36.230 回答