Keyboard Delegate
To cancel the keyboard when the Return key is pressed, see the 'textFieldShouldReturn' message in the
UITextFieldDelegate Protocol.
Basically, you'll need to wire the UI Input field's delegate outlet to the view controller (drag the outlet to the "File's Owner" socket).
Then implement the
textFieldShouldReturn message by calling
resignFirstResponder.
The
textFieldShouldReturn message can be linked to multiple UI Input fields.
- - (BOOL)textFieldShouldReturn:(UITextField *)textField {
- [textField resignFirstResponder];
-
- return YES;
- }
Reuse a Table Cell
Instead of allocating a new cell for every row in a large UI table, you can recycle old cells as they become eligible for reuse
(e.g., a row has scrolled out of the visible region).
Use the
dequeueReusableCellWithIdentifier message to find the next available cell.
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
UITableViewCell* result = [tableView dequeueReusableCellWithIdentifier:@"id1"];
-
- if (result == NULL) {
-
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"id1"];
- }