Question

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???

Was it helpful?

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];

OTHER TIPS

I'm not sure why you are using a UINavigationController. If it is because you would like your toWebMsgController controller to have a nav bar when it loads in the modal view, try the following alterations to your code:

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

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:toWebMsgController];

//[navController pushViewController:self.toWebMsgController animated:NO];

[self presentModalViewController:navController animated:YES];

If you don't require a nav bar in your modal view, you probably don't need a UINavigationController at all.

I had same issue.

Check that you root controller (if you present controller over it) for presentationStyle DOES NOT set to UIModalPresentationCurrentContext

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top