如何在 splitview 控制器的详细视图中显示 tableview 中所选行的数据?

发布于 2024-10-07 09:40:20 字数 194 浏览 4 评论 0原文

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

我想要做的是点击主视图的一行并在详细视图控制器上但在表视图中显示详细信息。

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

有什么建议吗?

提前致谢。

I've managed to read some values into a table view and display them in the Master View of a SplitViewController.

What I would like to do is to tap on a row of the Master View and display the details on the detailViewController but in a TableView.

When I tap on the row in the MasterView table, I can't seem to get the detail to populate the detailview TableView.

Any suggestions?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

┈┾☆殇 2024-10-14 09:40:20

您需要执行以下操作:

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

Here's what you need to do:

  • Add an outlet to your master view controller which is a link to your detail view controller
  • Connect this outlet (either in Interface Builder or in code)
  • Add properties to your detail view for the values you're interested in displaying
  • in your implementation of tableView:didSelectRowAtIndexPath: retrieve the data for the selected row and set the corresponding properties in your detail view
所有深爱都是秘密 2024-10-14 09:40:20

阅读这个基础教程。

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

查看示例代码,看看您做错了什么或缺少

什么编辑:它是 splitViewController 的教程。

Read this basic tutorial.

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

Go through the sample code and see what you are doing wrong or missing

EDIT: its a tutorial on splitViewController.

意中人 2024-10-14 09:40:20

可能此代码对您

表视图

- (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文件中的表视图.m文件中有所帮助

@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;

may be this code is help for you

in table View .m file

- (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]];



}

in table view .h file

@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;

in DetailsViewController.h file

UITextField *noteTitelFiled;
UITextView *notediscView;

DocumentNavController *noteObj;

@property (nonatomic, retain)IBOutlet UITextField *noteTitelFiled;
@property (nonatomic, retain)IBOutlet UITextView *notediscView;
@property (nonatomic, retain)DocumentNavController *noteObj;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文