G'day guys, I'm building an application that allows users to rapidly input numbers into a UITableView
.
I've currently built the framework, but I'm having a bit of a hitch hooking up the view to have the keyboard load and make the text in the cell editable from a user action.
I remember there being an iOS example in the dev code somewhere, (like a year ago so it wouldn't be under NDA) where you added items in and edited them within the context of the UITableView
without going to a detailed subview.
Just need a hint on how to hook up the delegates, or how to structure the code.
I have code where I create custom cells for a UITableView
which have UITextField
and UITextView
controls on them. In the UITableViewController
code I do this:
Interface
@interface MyTableViewController:
UITableViewController <UITextFieldDelegate, UITextViewDelegate> {
....
}
Implementation
-(UITableViewCell *) tableView:(UItableView *) tableView
cellForRowAtIndexPath: (NSIndexPath *) indexPath {
....
UITableViewCell * cell = ....
cell.myTextField.delegate = self;
cell.myTextField.tag = 1; //This should be unique.
return cell;
}
-(void) textFieldDidEndEditing: (UITextField * ) textField {
// Decide which text field based on it's tag and save data to the model.
}
-(void) textViewDidEndEditing: (UITextView * ) textView {
// Decide which text view based on it's tag and save data to the model.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With