status bar and Navigation bar problem after dismissed modal view - iphone

the apps launched the mailcomposer modal view (MFMailComposeViewController) when the Contact Us button is pressed.
but once the modal view is loaded, the status bar is hidden automatically.
I setStatusBarHidden Status to NO after modal view controller is dismissed.
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
but the status bar and navigation bar is overlapped after ModalViewController is dismissed.
I got no clue how to fix it.
Appreciate any kind help.
Thanks.

my problem is solved by launching the MFMailComposeViewController from appDelegate tabBarController
myAppDelegate *mDelegate = (myAppDelegate *)[[UIApplication sharedApplication] delegate];
[mDelegate.tabBarController presentModalViewController:picker animated:YES];
instead of launching from the navigation Controller
[self presentModalViewController:picker animated:YES];

Related

How to navigate to the previous page in iphone

How to navigation to previous page!
I add navigation controller to appDelegate so thought out the application i do have navigation controller.
I hidden navigation Bar and added HeaderView on the top.
// Hidden NavigationBar
- (void) viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
Now customize my header bar with UIView! I hidden navigation Bar and added HeaderView on the top.
Now i added BackButton to the header Bar. Now i want to navigation pervious page. Can any one suggest me?
#Thanks In Advance.
if the view is called by a push action, call :
[self.navigationController popViewControllerAnimated:YES];
else if the view is displaying by a modal call :
[self dismissModalViewControllerAnimated:YES];
Use [self.navigationController popviewControllerAnimated :YES];
Use this when the user taps the Back button:
[self popViewControllerAnimated:YES];

View shifts up by 20px after closing the modal view

I am working on storyboard based application (iPhone). Application has a Navigation Controller to start with. We are integrating an existing application with it. Thus we need to load the NIB file on click of a button.
NSBundle *someBundle = [NSBundle category_bundle ];
MainWindow *aViewController = [[MainWindow alloc]
initWithNibName:nibName
bundle:someBundle];
[self.navigationController pushViewController:aViewController animated:YES];
The existing application then loads another VC.
[[self navigationController] pushViewController:mySecondView animated:YES];
This view again comes from NIB.
This view then uses a singelton to get the instance of MainWindow (loaded in first step) and request it to show a modal view. "Bad Design" but I can not change it as this is an existing application and I need to deliver the integration tomorrow.
Modal is shown as -
[self presentModalViewController:aModal animated:YES];
We are opening the modal in landscape and for that in its viewWillAppear we are using this code-
[UIApplication sharedApplication].statusBarOrientation = self.interfaceOrientation;
and in viewDidDisappear
if (SYSTEM_VERSION_LESS_THAN(#"5.0")) {
[UIApplication sharedApplication].statusBarOrientation = self.parentViewController.interfaceOrientation;
} else {
[UIApplication sharedApplication].statusBarOrientation = self.presentingViewController.interfaceOrientation;
}
Question:
The problem is that UIView of MainWindow moves up by 20px after the modal pop up has been closed. I have tried to reset the frame. Also tried to hide the status bar but then status bar partially hides the navigation bar, to resolve this we tried to hide the navigation bar after the status bar has been made visible and then showing it again, but with no success.
Please let me know how can I resolve this issue.

Dismiss ModalViewController from subview

I have a problem with the function call:
[self dismissModalViewControllerAnimated:YES];
In MainViewController, I can launch a image picker and dismiss as usual by clicking the cancel button.
(IBAction) LaunchInMain:(id)sender{
MainAppDelegate *app = (MainAppDelegate *)[[UIApplication sharedApplication] delegate];
//elcPicker is a customized image picker
[app.viewController presentModalViewController:elcPicker animated:YES];
[elcPicker release];
[albumController release];
- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker {
[self dismissModalViewControllerAnimated:YES];
}
Now, instead of launching it direct it in Main, I add a subview first and launch the image picker from the subview using the same launch method.
Problem:
The image picker cannot be dismissed and the subview cannot be shown again. So the screen will remain at the image picker no matter what I click.
I have been trying with some other calls like without any success:
[self dismissModalViewControllerAnimated:YES];
I am happy with any help or idea. If you think more information should be provided, I can add more codes.
May be try
[app.viewController dismissModalViewControllerAnimated:YES];
Hope this helps.
This may work for you:
[self.view dismissModalViewControllerAnimated:YES];
This works if you are presenting a modal view from a UISplitViewController. It can also be applied in so many other ways...
First, create an instance in your .h file for your appDelegate, (AppDelegate_iPad *appDelegate) then put this in your viewDidLoad or comparable method:
ipadDelegate = (AppDelegate_iPad *)[[UIApplication sharedApplication] delegate];
Now, present the first modal view like this:
YOURVC *vc = [[YOURVC alloc] initWithNibName:#"YOURVC" bundle:nil];
[ipadDelegate.splitViewController presentModalViewController:vc animated:YES];
[vc release];
Say you have a subview, like a UITableView, and want to dismiss the modal from the didSelectRowAtIndexPath. All you have to do to dismiss your modal with a subview is create another ipadDelegate instance inside your subview's .h (if needed), reference the [[UIApplication sharedApplication] delegate] again, and dismiss:
[ipadAppDelegate.splitViewController dismissModalViewControllerAnimated:YES];
Essentially, as long-winded as it may be, use your appDelegate's controller to present and dismiss the the modal if you need to maintain a persistent reference to the presentingViewController...because all the things above just don't work in my case.
If you're presenting with your ipadDelegate, make sure you check the mode of presentation in your MainWindow_iPad.xib. Your "Transition Style" should be "Cover Vertical" and "Presentation" should be "Current Context" or your modal may present behind other views.

After dismissModalViewControllerAnimated: my tabbar disappears

I have an app which consists of three layers of view controllers: UITabBarController => UINavigationController => UIViewController. They are all generated in code rather than using IB. The tab bar is on the bottom as per the usual design guidelines. In my UIViewController I am using this code to present the modalViewController:
myModalVC = [[MyModalViewController alloc] init];
[self.navigationController presentModalViewController:myModalVC animated:YES];
This work fine and the modal view controller pops up and covers the entire screen.
However when a button is pressed within the modal view controller, I run this:
[self dismissModalViewControllerAnimated:YES];
And the modal view controller animates away. However I can see the original UIViewcontroller view but the tab bar disappears completely. I've googled a lot but I can't find anyone that has this same problem.
You should delegate your modal view controller to your parent view controller. [self dismissModalViewControllerAnimated:YES]; should be done by the delegate and not the modal view itself, parent view are responsible for dismissing the modal view.
Actually I found this by googling a bit more. I made my tab bar controller a property of the app delegate and when it presents the modal vc, it does this
UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController presentModalViewController:myModalVC animated:YES];
Then it dismisses it by this bit of code
UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController dismissModalViewControllerAnimated:YES];
This fixes the the tab bar disappearing.
Try
[self.navigationController dismissModalViewControllerAnimated:YES];
Thanks for your answer! I had the same problem, but I'm writing in Swift, so thought I'd include my solution that I figured out from looking at yours. I only had to use these two lines to fix the problem. Nothing else was needed.
tabBarController?.presentViewController(viewController, animated: true, completion: nil)
and
tabBarController?.dismissViewControllerAnimated(true, completion: nil)
I should also mention that the line: tabBarController?.delegate = self, is in the viewDidLoad function of my NavigationController.

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.