Modal view not displaying properly
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". 开发者_如何学CHowever, 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.
精彩评论