views:

2004

answers:

2

I know it might not be according to Apple's human interface guidelines for the iPhone, but I want to get rid of one level of pushing views and have a list of editable text fields. Further, I want the keyboard to be on screen from start when the view appears.

The problem is that when I have more than three such fields then the pop-up keyboard will cover the fields below. And the user can't scroll down to them. I think it's because the table view is full-screen. I've tried to make the list only as heigh as it would allow the keyboard to be visible all the time, but no luck.

Anyone knows how I should arrange things to get what I want?

+2  A: 

If you truly never need the keyboard to go away, The UITableView does not have a reason to be fullscreen. You can change the frame like this (where HEIGHT is the number of pixels the tableview will take up between its origin and the top of the keyboard):

tableView.frame = CGRectMake(0,0,320,HEIGHT);

Brad Smith
+1  A: 

If you insist on forcing the user to live with such a small input area the whole time, you can facilitate text input by having the return key also automatically jump to the next text input field by overriding the UITextEditDelegate method:

- (BOOL)textFieldShouldReturn:(UITextField *)textField
    {
        if ( textField == self.firstNameField )
        {
            [self.lastNameField becomeFirstResponder];
        }
        else if ( textField == self.lastNameField )
        {
            [self.addressField becomeFirstResponder];
        }
        else if ( textField == self.addressField )
        {
            [self.cityField becomeFirstResponder];
        }
        else if ( textField == self.cityField )
        {
            [self.stateField becomeFirstResponder];
        }
        else if ( textField == self.stateField )
        {
            [self.zipcodeField becomeFirstResponder];
        }
        else if ( textField == self.zipcodeField )
        {
            [textField resignFirstResponder];

            [self.scrollView scrollRectToVisible:self.firstNameField.frame animated:YES];
        }


        return YES;
    }

This example will let the user input the fields for name & address in order without having to manually scroll the next text field into view and without the keyboard dismissing and reappearing.

God of Biscuits