views:

56

answers:

1

I have an application with a UITableView with grouped style. On each of the cells, there is a UILabel with a description, and a UITextField for the user to enter data.

We implemented a toolbar on top of the keyboard, with next and prev buttons (similar to what MobileSafari provides when filling forms). In order to give focus to the next field, we resorted to using the tag attribute with consecutive numbers, and we find the subview by tag.

We can't use the responder chain because all the textfields have a different parent view (their UITableViewCell).

However, when using the iPhone Simulator, the Tab key on the keyboard (and Shift-Tab) work as expected and will move the focus to the next or prev textfield, regardless on where it is in the view hierarchy. After seeing that, we are sure there must be an API that provides us the required functionality, but we could not find it. Any hints?

A: 

I'm not sure exactly what functionality you are trying to implement.

However, I suspect it will be of interest to you that you can access the controller from the cells as follows:

UITableView *myTableView = (UITableView *)self.superview;
NSIndexPath *indexPath = [myTableView indexPathForCell: self];
MyTableViewController *myTableViewController = (MyTableViewController *)(myTableView.delegate);

Once you have messaged the controller, it in turn can access whatever cell is desired with cellForRowAtIndexPath.

William Jockusch
I'm looking for text fields inside cells, and I'm looking for a way to get the next one automatically.
pgb
Well, it's not the most direct thing in the world, but the above will work -- your cell messages the controller as above, and the controller in turn messages the next cell.
William Jockusch