iMessage broken after iMessage extension app tries to open keyboard.

Our iMessage extension app has a UITextField. As soon as the textfield is selected (ie. when the keyboard should appear), the extension app's view disappears and the "new message" input UI disappears as well, making it impossible to create new messages.

Replies

If you're referring to this being in compact layout mode, then you shouldn't have a text field there. Text entry should only be done in expanded mode.

Could you elaborate on why that is?


What I'm trying to achieve is to enable the user to create a video according to the typed text. Since I can't read the text from the input box of iMessage, I'd like him to type it in the extension.


There's only an input and a button in my extension, so I'd prefer to remain in compact mode.


Thanks.

@pdm - on a very related question regarding keyboard covering up the screen like in compact mode - even in expanded mode on iPhone 5 class devices, the keyboard (and top bar and bottom bar) take over most of the screen - preventing any text box value from being seen. Does Apple have a preference of 1) allowing user to do this even though they can't see what they are typing or 2) telling user they need to be in portrait mode to enter text?


There's plenty of space if they rotate into portrait mode.


@guggy - if you are in compact mode, you can't see what you are typing as the keyboard takes up almost the entire compact view - just like expanded mode in landscape.

I have the same issue, the iMessage portion down the bottom crashes and disappears. Is there any way that we can ensure the expanded view opens upon a textview being selected?

Set the delegate for the textField to self then add the following method:



-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {

    if ([self presentationStyle] == MSMessagesAppPresentationStyleCompact) {
        [self requestPresentationStyle:MSMessagesAppPresentationStyleExpanded];
        return NO;
    } else {
        return YES;
    }

}



Above the `return NO;` line you can add:

[self performSelector:@selector(becomeFirstResponder) withObject:textField afterDelay:0.5f];

if you want the text field to auto be selected (for editing) once the app has expanded to full-screen mode. Though the 0.5f time delay on that is undocumented and might not work on slower phones, going up to something like 1.0f delay would solve this for slower phones but only by making the UI slow for everyone. I find it best to just have tapping the textField once expand you to full screen mode, then tapping it again goes into editing mode (the code I originally proposed above), but do whichever you find best.