This is what 开发者_运维百科I have so far:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row)
{
// row 0 -> DetailViewController1 anzeigen...
case 0:
{
TableViewController *fvController = [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:[NSBundle mainBundle]];
fvController.selectedCellItem = selectedCellItem;
[self.navigationController pushViewController:fvController animated:YES];
[fvController release];
fvController = nil;
}
break;
default:
break;
}
So my question is: How can I change a UITextfield of the detailView by selecting a cell. Thank you for your help so far;)
Do you want to edit the text in a UITextField in a cell? If so, there are a few ways you can do this, I'll touch on two of them.
First, why don't u just edit the cell right from within the tableView? This entails you to keep track of each cell's contents but if you always have a custom cell with a UITextField in it, you're half way there.
If you want to make changes to the text in a regular cell, then the user selects it and you give them an edit screen, this is a lot simpler. You can have your tableView push a view controller with a textField that has the text from your cell. They can edit this textField, and then press save. When they save, pop the view off the stack, save the changes to the data model, and update the tableView.
I'm not sure exactly what you're trying to do, but having a textField in a cell and then making edits in a detail screen seems redundant.
If you provide us with a little more info, I'm sure we can help.
UPDATE based on your clarification
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row)
{
// row 0 -> DetailViewController1 anzeigen...
case 0:
{
ViewControllerName *vController = [[UIViewController alloc] initWithNibName:@"ViewControllerName" bundle:[NSBundle mainBundle]];
vController.textField.text = //set the text here from the data source. Assuming textField is an property of vController.
[self.navigationController pushViewController:vController animated:YES];
[vController release];
}
break;
default:
break;
}
精彩评论