0

我有UITableViewControlleratextLabel和 a ,问题是我detailTextLabel想传递一个让我们说“隐藏”的第三个值,它URL有 一个做这个?UITableViewControllerdidSelectRowAtIndexPath

4

1 回答 1

1

您可以将字典发送到下一个 TableView。将 SecondTableView 控制器 .h 文件导入 FirstTableView 控制器,然后引用目标字典。您还需要实现 prepareForSegue 并在 didSelectRowAtIndexPath 中调用它。像这样的东西:

在 didSelectRowAtIndexPath: 中:(如果您正在使用它,请确保在 Storyboard 中设置 segue 标识符)。

[self performSegueWithIdentifier:@"toSecondTableViewController" sender:nil];

在 SecondTableViewController.h 创建你的字典

@property (nonatomic, retain)NSMutableDictionary *selectedDictionary;

确保在 SecondTableViewController.m 文件中合成它。

然后在你的 FirstTableViewController

#import SecondTableViewController.h 
//prepareForSegue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"toSecondTableViewController"])
    {
        //create the dictionary to store the information from the array
        NSDictionary *dictionaryToPass;
//MainTable is your TableView in your TableViewController
        NSIndexPath *indexpath = [self.MainTable indexPathForSelectedRow];
        NSLog(@"IndexPath is: %@",indexpath);
        //load correct information based on indexpath selected

            dictionaryToPass = [array objectAtIndex:indexpath.row];

        //create the view for the segue
        SecondTableViewController *secondTable = segue.destinationViewController;

//pass the dictionary
        seriesTable.selectedDictionary = dictionaryToPass;
    }
}

然后,您可以在 SecondTableViewController 中引用 selectedDictionary 中的键并获取该 URL。

于 2013-01-09T19:31:59.173 回答