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 Tabl开发者_JS百科eView.
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.
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
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.
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;
精彩评论