I am writing an iPad app and want to put an option on the home screen (root view controller) to allow users to e-mail feedback. I would like the mail to appear with the style "UIModalPresentationFormSheet". However, when I run the code, it appears full screen. What am I doing wrong? Here is the code I am using:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toAddresses = [[NSArray alloc] initWithObjects:#"user#domain.com", nil];
[picker setToRecipients:toAddresses];
[toAddresses release];
[picker setSubject:#"App Feedback"];
self.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:picker animated:YES];
[picker release];
You must set the style of the viewController being presented, not on the one presenting it.. So set the property of the MFMailComposeViewController and you should be ok.
You need to set modalPresentationStyle on your new view controller, not self.
Related
I want to show new contact page on button click I have written this code within action button
{
ABNewPersonViewController *abnewpersonviewcontroller = [[ABNewPersonViewController alloc] init];
[self.navigationController pushViewController:abnewpersonviewcontroller animated:YES];
[newPersonController release];
}
this code succesfully reach me to the new contact page but the problem is navigation bar not shown onto the new contact page in which i can save record and also have cancel button on it kindly tell me how I can display the navigation on new contact page when I click on action button
use this
ABNewPersonViewController *abnewpersonviewcontroller = [[ABNewPersonViewController alloc] init];
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:abnewpersonviewcontroller animated:YES];
[newPersonController release];
ABNewPersonViewController *picker =[ABNewPersonViewController new];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:picker];
picker.newPersonViewDelegate =self;
[self presentViewController:nc animated:YES completion:nil];
did you hide navigation bar in your application?
if yes, then you should unhide before moving to contact page........
thanks
Well you can add self.navigationController.navigationBarHidden = NO; to that pushed view controller in - (void)viewWillAppear:(BOOL)animated method to force it but it should show automatically if you didn't added extra UINavigationBar to your UINavigationController.
I have a common action sheet (in NSObject class) that is called from multiple classes. One of the actions is launching email. Everything works great when called from the first NIB loaded. However, after I switch NIBs using modal views, the email (its own modal view) will not appear in any of these (but all other actions work fine). I presume it is because they are modal views and not the viewController called by the App's delegate. I presume the "rootViewController" below is the issue. I'm stuck. Help appreciated.
-(void)SendEmail {
// all this NSObject to send emails
rootViewController = (UIViewController*)[(AppDelegate*)[[UIApplication sharedApplication] delegate] viewController];
// compose
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
//controller.mailComposeDelegate = self;
controller.mailComposeDelegate = self;
//format message
NSArray *recipientsArray = [[NSArray alloc] initWithObjects:#"support#A___.com", nil]; // email recipients must be in an array
[controller setToRecipients:recipientsArray];
[controller setSubject:[NSString stringWithFormat:#"A question about %#",stuff]];
//[controller setMessageBody:outputMutString isHTML:YES];
//send
if (controller) {
NSLog(#"email controller");
[rootViewController presentModalViewController:controller animated:YES];
}
}
Does anyone have any ideas on the right way to do this? There is one answer to a similar question on here, but it's so convoluted, I can't imagine it being right. There has to be an easier way to just show the keyboard when this modal view pops up. right?
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"Mail subject"];
[picker setToRecipients:[NSArray arrayWithObjects:#"email#email.com",nil]];
i'm new with iPhone developpement and i try to lunch a UIviewController when the user pressed a button witch will allow the user too send an email.
So my AppControler is a NSObject witch contains a UIWindow and a UIViewController* myViewController
When i detect the click on the button i create this:
MFMailComposeViewController *picker =
[[MFMailComposeViewController alloc] initWithNibName:#"MainWindow"
bundle:nil];
picker.mailComposeDelegate = myViewController;
... set the mail
and then when i try to present the view controller with this
[myViewController presentModalViewController:picker animated:YES];
[picker release];
Nothing append..
i know it's simple but i cant figured it out what is wrong.
thanks
Try using:
[self presentModalViewController:picker animated:YES];
As #dannywartnaby mentioned unless myViewController points to the current view controller (self) it won't work.
MFMailComposeViewController displaying only bar at the top of the screen with the cancel and send buttons. Code for landscape:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:#"In app email..."];
[controller setMessageBody:#"...Hi, all...." isHTML:NO];
//[self presentModalViewController:controller animated:YES];
controller.view.frame = CGRectMake(0,0,480,320);
[self.view addSubview:controller.view];
[controller release];
What is problem?
i've ever seen this problem before, as far as i know, you shouldn't replace the presentModalViewController method with addsubview.
I was getting this behavior, as well as the modal view coming in from the side and the modal view was stopping a quarter of the way through presenting.
In my app I had many view controllers stacked with addSubview:. I don't know why but it worked to present the modal view from the bottom view controller. I did something like this:
[((FirstViewController*)[UIApplication sharedApplication].delegate).firstViewControllerInstance sendEmailwithInfo];
Hope that helps! And maybe someone can give some insite as to why it was happening.