Question

The UIAlertView message doesn't show properly when the text field in it is being edited (when the keyboard is being displayed). Here's how it looks like: enter image description here

When the keyboard isn't there: enter image description here

This is the code that creates the alert view:

        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Title"
                                  message:@"Enter a name for your recipe"
                                  delegate:self
                                  cancelButtonTitle:@"Cancel"
                                  otherButtonTitles:@"OK", nil];
        [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
        [alertView show];

Is there a way to change the size of some components of the view so that it fits properly in the screen when the keyboard is displayed?

Edit: I just discovered that the alert view becomes scrollable when the keyboard appears. So if you scroll down, you can see the message. But I didn't notice that the first time the alert view popped up, and other users might not either. For now, I'm using what Visput suggested.

Était-ce utile?

La solution

It is standard behavior for iOS. You could see the same layout in "Photos" application when create new Album in landscape mode.
I think the best way in this situation: place all text to message but title set to nil.
In your case:

UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:nil
                              message:@"Title: Enter a name for your recipe"
                              delegate:self
                              cancelButtonTitle:@"Cancel"
                              otherButtonTitles:@"OK", nil];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top