presentModalViewController NOT animating when showing a TTMessageController - iphone

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 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:
Add a property of type UIViewController to the UIViewController that will present a modal view controller (e.g. #property (nonatomic, retain) UIViewController *owningController;)
Set that property = to the topmost UIViewController (the one that contains the UIScrollView in this case)
In the UIViewController that shows the modal view ... change this
[self presentModalViewController:controller animated:YES];
to this ...
[owningController presentModalViewController:controller animated:YES];

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

Related

Modal ViewController has white stripe on bottom

I have a ViewController subclass that I'm presenting as a modal view:
MyViewController *myViewController = [[MyViewController alloc] init];
[self presentModalViewController:myViewController animated:YES];
However, the modal view showing up with a white stripe on the bottom, approximately the height of the title or navigation bar. My app is otherwise navigation controlled. How do I get rid of the white stripe (and ideally add a title bar)?
I'm not sure if this is one of two things from your question, are you trying to add a navigation controller to your modal view controller, or are you trying to hide your navigation controller from your modal view.
I suspect you may want to in fact change your code to the following to present your modal view controller from your NavigationController
MyViewController *myViewController = [[MyViewController alloc] init];
[[self navigationController] presentModalViewController:myViewController animated:YES];
Then call setTitle: on you MyViewController object to set the title for it.

self.navigationController pushViewController not working

I have a View application with a Single UIViewController. I then add a UITableViewController through the IB, and I am trying to display the UITableViewController through a button press in the UIViewController (my main view). My button press (IBAction) contains the following code through which I am trying to push my UITableViewController view and display it:
DataViewController *dataController = [[DataViewController alloc] initWithNibName: #"DataViewController" bundle:nil];
[self.navigationController pushViewController:dataController animated:YES];
[dataController release];
My DataViewController is not at all getting pushed into the stack and displayed,
Also I have checked that in the code above, self.navigationController=nil
Probably this is the source of the problem. If so, how to rectify it?
Please help.
UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:yourfirstviewController];
[self.window setRootViewController:navCtrlr];
navCtrlr.delegate = self;
navCtrlr.navigationBarHidden = YES;
Create navigation controller in appdelegate.m then you can navigate to any uiviewcontroller
You need to actually create a UINavigationController. The navigationController property tells you whether your DataViewController is currently in a UINavigationController's hierarchy; if not (as in this case), the navigationController property returns nil.

Presented modal navigationcontroller under current navigationcontroller iphone

In my application the modal navigationcontroller that I am presenting is going under the current navigationcontroller so I'm not able to view the new navigationbar as it's disappearing under the current one.
I'm presenting the modalview on self and not self.navigationcontroller because self.navigationcontroller doesn't present the modalviewcontroller.
Also how to push a view on this modal navigationcontroller?
I'm using following code in one of my viewControllers:
fullListTopCompanies *fullListTopCompaniesInstance = [[fullListTopCompanies alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:fullListTopCompaniesInstance];
fullListTopCompaniesInstance.navigationController.navigationItem.title = #"F";
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[fullListTopCompaniesInstance release];
Can anybody please help?
Thanx in advance.
use animated with transition
according to me you have to change the animation style
i done it before but forgot the code i will post it when i get it
self.navigationController.navigationItem.title = #"F";
Add the above line of code in viewDidLoad method of "fullListTopCompanies" class.
Actually your navigation bar hides because of the modal view and modal view by default doesnt have Navigation bar.To add a navigation bar to modal view you can try the below code:
In Header File
IBOutlet fullListTopCompanies *fullListTopCompaniesInstance;
In Implementation File
UINavigationController *nav = [[UINavigationController alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
[self presentModalViewController:nav animated:YES];
[nav release];
Also on the "fullListTopCompanies" View Controller dont forget to put a left navigation bar button item for dismissing the modal view.
So add that left bar button (Ideally Cancel Button on navigation bar) and event handler for that left barr button should contain the code
[self dismissModalViewControllerAnimated:YES];
Hope this helps.

UINavigationBar refuses to show in Modal View Controller

I am loading a Modal view controller using the following code in my RootViewController:
[self.navigationController presentModalViewController:accountViewController animated:YES];
In the accountViewController xib file, I have set a navigation bar. My MainWindow.xib and RootViewController.xib also have the navigation bar setup correctly. Additionally, my app delegate has setup the navigation controller (I assume) correctly:
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[window addSubview:navigationController.view];
However, when I load my accountViewController the UINavigationBar is nowhere to be seen. Is it not possible to show a UINavigationBar in a modal view? I was planning to use it to hide the back button, and add a right button...
sha's answer is correct, but I'm giving my own answer to expand on it with a code example to make it clear.
You probably want something like:
- (void)showAccountViewController
{
AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:#"AccountView" bundle:nil];
...
// Initialize properties of accountViewController
...
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];
[accountViewController release];
}
You need to push not viewController but navigationController that has viewController inside.
You can also set the presentation style in the Attribute Inspector to "Current Context". Modal View will not cover the Navigational Bar.

presentmodalviewcontroller navigationcontroller

I am creating a Navigation based iPhone application.
In that I have called a UiViewController using presentModalViewController. After that, the ViewController becomes visible. From that ViewController I need to call another ViewController using the sample presentModalViewController. Is this possible or not?
What do you mean by "call another uiviewcontroller"? (It really helps if you can be more detailed in your question.) If you mean, "slide in another view controller", then:
MyNewViewController *myNewViewController = [[MyNewViewController alloc] initWithNibName:#"MyNewViewController" bundle:nil];
[navigationController pushViewController:myNewViewController animated:YES];
[myNewViewController release];
...where:
MyNewViewController is the new view controller class that you want to slide in (the above code assumes you have an XIB file for the view controller class).
navigationController points to the current navigation controller. You'll have to replace it with something like [self navigationController], depending where you are in the view hierarchy.
U might be using following line to present a view controller.
//assume name of viewController which u want to present is "myViewController"
[self.navigationController presentModalViewController:myViewController animated:YES]
If you want to push an other ViewController or present an other ViewController then u will need to replace above line with following lines.
//[self.navigationController presentModalViewController:myViewController animated:YES];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
navigationController.navigationBarHidden = YES; //if u want to show navigation bar then remove this line
[self presentModalViewController:navigationController animated:YES];
After using above code you can present or push other view controllers within presented view controller.
Hope it will solve your problem :)