views:

311

answers:

2

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

A: 

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.

dl
Nope ... results in same behavior. Btw, I've tried showing without the navigation controller and the behavior is the same as well.
wgpubs
Hmmm. I'm not sure what it could be then. I've never had any trouble presenting TT* controllers modally with animation. I've never used TTMessageController though as iPhoneSDK 3+ has the native MFMailComposeViewController available. Are you able to present a non-TT* controller correctly from your UIViewController class?
dl
Actually yes ... its happening with all my controllers now. I'm using FTUtils, ASIHTTPRequest and Three20 in the project so I'm wondering if there is some conflict??? I am getting a number of "warnings" about "RGBACOLOR" being redefined ... but nothing else.
wgpubs
Whatever the issue is, I think it's safe to say that the problem is not the code that you posted. Good luck!
dl
A: 

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