Search code examples
iphoneobjective-cxcodethree20presentmodalviewcontroller

presentModalViewController NOT animating when showing a TTMessageController


I have a subclass of TTMessageController that shows ... BUT it is not animated even though it should be. The code that displays the modal view looks like this (where PostToWebMessageController is the subclass of TTMessageController:

if (self.toWebMsgController == nil) {
    self.toWebMsgController = [[PostToWebMessageController alloc] init];
}

UINavigationController *navController = [[UINavigationController alloc] init];
[navController pushViewController:self.toWebMsgController animated:NO];

[self presentModalViewController:navController animated:YES];

What happens though is this: The screen goes black ... the keyboard scrolls up into view ... and THEN the TTMessageController view shows up (not animated). When I dismiss the view via a Cancel button the screen goes black and then just disappears (no animation again).

Any ideas why this is happening? I've this with a number of other TT* controllers and I can't get one to animate right with showing modally.

Thanks

UPDATE:

This is happening in EVERY UIViewController that I try to present modally. Screen goes black, keyboard animates upwards and then view displays. Any ideas why this might be happening???


Solution

  • A day to figure this out ... hopefully someone will benefit from my pains!

    Here is what is happening:

    The UIViewController calling presentModalViewController is itself nested inside a UIScrollView that is contained in ANOTHER UIViewController. Apparently, cocoa touch doesn't much like this. Anyhow, to rectify the problem I did the following:

    1. Add a property of type UIViewController to the UIViewController that will present a modal view controller (e.g. @property (nonatomic, retain) UIViewController *owningController;)

    2. Set that property = to the topmost UIViewController (the one that contains the UIScrollView in this case)

    3. In the UIViewController that shows the modal view ... change this

    [self presentModalViewController:controller animated:YES];

    to this ...

    [owningController presentModalViewController:controller animated:YES];