MFMailComposeViewController

Discussion in 'iOS Programming' started by ppn, Mar 23, 2011.

  1. ppn macrumors member

    Joined:
    Oct 31, 2010
    #1
    I have a Navigation View with a tab bar delegate so basically it has tab bars and a navigation bar. I'm trying to implement a "Refer a Friend" button where the user will click the button and a mail view will pop up. I'm using the MFMailComposeViewController but my navigation bar is covering the navigation bar for the mail composer so I can't click on the "Cancel" and "Send" button. I tried both self.navigationController.navigationBarHidden = YES and [[self navigationController] setNavigationBarHidden:YES animated:NO] but the navigation bar just won't go away. Anyone have suggestions for this? Do I need to send the mail controller view to the front to hide the navigation bar for my view controller?


    Code:
            self.navigationController.navigationBarHidden = YES;
    		MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
    		[controller setToRecipients:recipient];
    		[controller setSubject:subject];
    		[controller setMessageBody:message isHTML:NO];
            controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    		[self presentModalViewController:controller animated:YES];
    		[controller release];
     
  2. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #2
    Did you make an IBOutlet for the nav bar? If so...
    Code:
    myNavBarName.hidden=YES;
    should work.

    Nick
     
  3. ppn thread starter macrumors member

    Joined:
    Oct 31, 2010
    #3
    No I didn't. The nav bar comes automatically because in my previous view, I pushviewcontroller so I didn't need to make an IBOutlet.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  5. ppn thread starter macrumors member

    Joined:
    Oct 31, 2010
    #5
    Self is a UIViewController. I basically have a TabBarController which is a UIViewController with tab bar at the bottom so I can use both a navigation controller and a tab bar. Then I have 3 different view controllers for the 3 different tabs. This code falls in one of the view controllers but I can't seem to get rid of the navigation bar.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    So if you open the UIViewController documentation do you see any properties that might let you access the navigation controller?
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Is the UINavigationController the parent of the UITabBarController or vice versa?

    Also, have you verified that self.navigationController is non-nil?
     
  8. ppn thread starter macrumors member

    Joined:
    Oct 31, 2010
    #8
    I don't have my mac in front of me right now but my structure is like this

    UIViewController (Home screen) --> UIViewController (With tab bars) --> UIViewController (with the email function).

    What should I do if the self.navigationController is nil?
     
  9. dejo, Mar 24, 2011
    Last edited: Mar 24, 2011

    dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    I would suggest waiting to tackle this problem until it is. Troubleshooting without access to debugging is very hard.

    I'm still not clear where the UITabBarController and especially the UINavigationController fits in this hierarchy.

    Well, you're not going to be able to hide the navBar if it is.

    But, I don't think that is really the right approach anyways. Feels more like a band-aid to me. You should be able to present your mail composer view modally and not have to worry about its navBar being obscured. Modal views should be presented over top of any other views and not within them. So, I would try to diagnose why that's not happening for you, first.
     
  10. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #10
    What happens if you don't set the modalTransitionStyle?
     
  11. Deepthi macrumors newbie

    Joined:
    Oct 13, 2008
    #11
    Even I am facing the same problem .. If you find the solution please tell me how to do it.
     

Share This Page