Reputation: 53
I have created a viewbased application, having modal linked viewcontrollers for an Iphone storyboard without a Navigation Controller. For One of my View Controllers i have designed a tableview with dynamic cells:
- (void)viewDidLoad {
[super viewDidLoad];
tabledata =[[NSArray alloc] initWithObjects:@"Data Mining",@"Software Quality",@"Project Management",@"Data Base", nil];
tablesubtitles =[[NSArray alloc] initWithObjects:@"Test parsing and KDD",@"Management of Software Creation Cycle",@"Roles in a Project",@"Database Lifecycle process", nil];
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [tabledata count];
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell=nil;
cell= [ tableView dequeueReusableCellWithIdentifier:@"Cell1"];
if (cell == nil) {
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell1"];
}
cell.textLabel.text= [tabledata objectAtIndex:indexPath.row];
cell.detailTextLabel.text =[tablesubtitles objectAtIndex:indexPath.row];
return cell;
}
Next thing i would like to implement is to link tableview rows to a ViewController which has a couple of textboxes available on it. The big idea is that on selecting a TableItem i want to load a ViewController and populate automatically textboxes based on selected items, also it would be good to have an edit/save possibility.
For Example: I have a Tableview with items
Dodge Chrysler Chevrolete Ford
On pressing "Dodge" a new ViewController appears having multiple TextBoxes and data is filled in with some details like "Since 1900". On editing the "Since 1900" textbox and pressing Save button, the control returns to viewcontroller with TableView in it.
After pressing "Dodge" the second time previously saved items are displayed.
I've tried a lot of variants, combinations how to achive it, I am new to Xcode and any help would be much appriciated.
Thank you in advance.
Upvotes: 0
Views: 329
Reputation: 484
It's not hard. Basically you just need to implement didSelectRowAtIndexPath
in your UITableView delegate. To see how to do this, create a new project in XCode and make it a MasterDetail application. That gives you the boilerplate code for a table view with selectable rows. The Master view is your table, the Detail view is how you handle the selected row.
Upvotes: 1