【问题标题】:How can i display the data of the selected row from the tableview in the detail view in a splitview controller?如何在 splitview 控制器的详细视图中显示 tableview 中所选行的数据?
【发布时间】:2010-12-15 12:21:43
【问题描述】:

我已经设法将一些值读入表视图并将它们显示在 SplitViewController 的主视图中。

我想做的是点击主视图的一行并在 detailViewController 上显示详细信息,但在 TableView 中。

当我点击 MasterView 表中的行时,我似乎无法获取详细信息以填充 detailview TableView。

有什么建议吗?

提前致谢。

【问题讨论】:

  • 我是否需要为要在其上显示详细信息的 TableView(位于 detailview 上)使用单独的“Ipad view with Controller”类型文件,或者我需要为它创建子类detailcontroller.xib.cs 文件本身中的这个表视图?请帮帮我。

标签: iphone uitableview uisplitviewcontroller


【解决方案1】:

这是你需要做的:

  • 为您的主视图控制器添加一个插座,它是您的详细视图控制器的链接
  • 连接此插座(在 Interface Builder 或代码中)
  • 将属性添加到您有兴趣显示的值的详细视图中
  • 在您的tableView:didSelectRowAtIndexPath: 实现中检索所选行的数据并在您的详细视图中设置相应的属性

【讨论】:

  • 嗨丹尼斯,你能不能说得更具体一点,因为我是这个领域的新手。谢谢。
【解决方案2】:

阅读此基础教程。

http://doronkatz.com/ipad-programming-tutorial-hello-world

浏览示例代码,看看你做错了什么或遗漏了什么

编辑:它是关于 splitViewController 的教程。

【讨论】:

    【解决方案3】:

    也许这段代码对你有帮助

    在表格中查看.m文件

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if(self.dvController == nil){
        DetailsViewController *viewControoler = [[DetailsViewController  alloc]initWithNibName:@"detailsViewController" bundle:[NSBundle mainBundle]];
        self.dvController = viewControoler;
        [viewControoler release];
    }
    
    DocumentNavController *docObjNew = [appdelegate.noteArray objectAtIndex:indexPath.row];
    
    [docObjNew hydrateDetailViewData];
    //
    dvcontroller.noteObj = docObjNew;  //noteobj reference  from in DetailsViewController.m file DocumentNavController *noteObj;
    
    dvcontroller.currentindex = indexPath.row;
    
    
    [self.navigationController pushViewController:self.dvController animated:YES];
    
    self.dvController.title = [docObjNew noteTitle];
    [self.dvController.noteTitelFiled setText:[docObjNew noteTitle]];
    [self.dvController.notediscView setText:[docObjNew noteDisc]];
    
    
    
    }
    

    在表格视图.h 文件中

    @interface DocumentTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
    
    UITableView *documenttableView;
    
    evernoteAppDelegate *appdelegate;
    UINavigationController *navControll;
    DetailsViewController *dvcontroller;
    DocumentNavController *docNavContro;
    
    //NSIndexPath *selectIndexPath;
    
    
    }
    
    @property (nonatomic, retain)DetailsViewController *dvController;
    @property (nonatomic, retain)DocumentNavController *docNavContro;
    @property (nonatomic, retain)UITableView *documenttableView;
    

    在 DetailsViewController.h 文件中

    UITextField *noteTitelFiled;
    UITextView *notediscView;
    
    DocumentNavController *noteObj;
    
    @property (nonatomic, retain)IBOutlet UITextField *noteTitelFiled;
    @property (nonatomic, retain)IBOutlet UITextView *notediscView;
    @property (nonatomic, retain)DocumentNavController *noteObj;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-03
      • 1970-01-01
      相关资源
      最近更新 更多