开发者

Saving data in a Table View Cell View

开发者 https://www.devze.com 2023-03-22 20:35 出处:网络
In my application I have a table view and the user is able to add and delete cells in that table view. When the user clicks on a cell that the开发者_开发技巧y have created, it gets pushed with a nav c

In my application I have a table view and the user is able to add and delete cells in that table view. When the user clicks on a cell that the开发者_开发技巧y have created, it gets pushed with a nav controller to a new view. In that new view, I have about 8-10 TextFields that the user can edit. My problem is, how would I get the viewcontroller to save the data the user inputs into the cell. I've gotten it to save, but the problem is that when I enter data in one cell, it adds it to every other cell since each cell goes to the same view. How can I save the data for each cell created?


i hope this code help you this code is not for saving data this is selected table cell display each recode details in details view

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号