iphone - 如何将segue ios5 Storyboard uitableview中的数据传递到详细 View

标签 iphone uitableview ios5

我正在使用 Storyboard在 ios5 中创建一个应用程序。我在导航 Controller 中嵌入了一个 tableviewcontroller,当您单击 tableviewcontroller 中的单元格时,有关该单元格主题的一些详细信息应该传递到详细 View 。我使用 plist 来填充表格 View 和详细 View 。我在没有使用 Storyboard的情况下做得很好,但想学习如何使用 Storyboard。我有顺序从 tableviewcontroller 转到我的详细 View 。

我的序列代码是:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"DetailViewControllerSeque"])
    {   DetailViewController *detailViewController = [segue destinationViewController];  
        NSString *path = [[NSBundle mainBundle] bundlePath];
        NSString *finalPath = [path stringByAppendingPathComponent:@"questList.plist"];
        NSArray *tempArray = [finalPath valueForKey:@"description"];
        NSString *descriptionString = [tempArray valueForKey:@"description"];
        detailViewController.detailDescriptionText.text = descriptionString;    
    }
}

感谢您的帮助。

最佳答案

我也遇到了同样的问题(由于缺乏 iOS5 的经验)。

事实证明,这是一个使用 iOS5 SDK 的示例应用程序,它有一个表格 View ,当点击表格单元格时使用 Segues:“Simple Drill Down”。

https://web.archive.org/web/20130513140140/http://developer.apple.com:80/library/ios/#samplecode/SimpleDrillDown/Introduction/Intro.html

您确实在表格单元格中设置了segue,并在 Storyboard文件中为其指定了名称。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    /*
     When a row is selected, the segue creates the detail view controller as the destination.
     Set the detail view controller's detail item to the item associated with the selected row.
     */
    if ([[segue identifier] isEqualToString:@"ShowSelectedPlay"]) {

        NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
        DetailViewController *detailViewController = [segue destinationViewController];
        detailViewController.play = [dataController objectInListAtIndex:selectedRowIndex.row];
    }
}

关于iphone - 如何将segue ios5 Storyboard uitableview中的数据传递到详细 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7937035/

相关文章:

iphone - 带有 ARC 的新 iPhone cocos2d 项目

javascript - safari 中弹出警报(iPhone)

ios - 调整 UITableViewCell 高度会导致更新结束时崩溃

ios5 - 每个 Twitter API 请求都必须存在于 ACAccount 请求中吗?

ios - 在 UIView2 上方显示 UIView1,但按输入方式将 UIView2 置于 UIView1 上方

iPhone 推送通知在沙盒中有效,但在生产模式下无效

iPhone - 比较一个 nil NSString 与另一个有值(value)的 NSString 返回 NSOrderedSame

iphone - 如何删除最后一行并在 TableView 中添加更多行?

ios - 剪辑/控制表格 View 的滚动

iphone - 带有部分、不连续填充区域的进度条 - iOS