MFMailComposeViewController displaying only bar - iphone

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.

Related

AQGridView - Orientation change in ExpanderDemo

I just started checking AQGridView and new to iOS too in the source example ExpanderDemo the orientation is working fine for the first View but as i click any cell and next upcomming AQGridView does not effect View on GridView.
ExpandingGridViewController *controller = [[ExpandingGridViewController alloc] init];
controller.gridView.frame = self.gridView.frame;
[self.gridView setHidden:YES];
[self.view.superview addSubview: controller.gridView];
[controller expandCellsFromRect: expandFromRect ofView: cell];
[controller viewDidAppear: NO];
On the other hand if i present the view controller to second it works fine with the orientation but losses the Animation for Expansion; which i don't want to loose. What should i do?
ExpandingGridViewController *controller = [[ExpandingGridViewController alloc] init];
[self presentViewController:controller animated:NO completion:nil];
The last time I use AQGridView I got a lot of troubles, I suggest You should give a try to UICollectionView. Cheers!

Form Sheet Modal View Animations

I have UIModalPresentationFormSheet views appearing in my app. Some of them appear from the Right some from the Bottom and the dismissing seems random. Some disappear to the Bottom some go Left some go Up. Is there a way to set the direction they appear from and dismiss to?
Code I use to present (this same code, just different viewcontroller being presented, called from the same view controller has varying animations for different modal views):
MyViewController *newModalView = [[MyViewController alloc] init];
newModalView.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:newModalView animated:YES];
Then in the modal view I call this to dismiss it:
[self dismissModalViewControllerAnimated:YES];
This is a known bug and is being worked on by apple.
Try something like this:
newModalView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
All the transition Styles:
newModalView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
newModalView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
newModalView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

iphone MFMessageComposeViewController, status bar problem

I'm using the following code to show in-app sms. My app don't have a status bar. (I'm using 320x480 pixels screen in portrait view)
if ([MFMessageComposeViewController canSendText])
{
MFMessageComposeViewController* msgController = [[MFMessageComposeViewController alloc] init];
msgController.recipients = [NSArray arrayWithObject:self.globalSMS];
msgController.messageComposeDelegate = self;
[self presentModalViewController:msgController animated:YES];
[msgController release];
}
This is working good to display the message view controller. (But status bar comes back, which is not necessary for me to show)
But the problem is that when I click "Cancel" or "Send", after going back to application, I am seeing white space on the top (in position of status bar) of the screen. And status bar is hidden.
Why is it happening when my status bar is set as hidden in app delegate. How to get rid of white space after showing the in-app sms view.
Hide the status bar after you modal presented the message controller. Something like this:
controller.wantsFullScreenLayout = NO;
[self presentModalViewController:controller animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Also Answered here: MFMessageComposeViewController not properly displayed
I found the answer. We've to set in view controller's viewDidLoad method:
self.wantsFullScreenLayout = YES;
The issue is in portrait view. From what I am seeing if the MFMessageComposeViewController loads in landscape the space isn't there. Then if the orientation changes to portrait the layout is corrected and the space isn't present in portrait.
Note When in landscape the MFMessageComposeViewController is presented by sliding from left to right. I believe that the way the view is presented holds to key to fixing the issue.
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]){
controller.body = #"MessageText!!!";
controller.recipients = [NSArray arrayWithObjects:#"123"];
controller.messageComposeDelegate = self;
controller.wantsFullScreenLayout = YES;
[self presentModalViewController:controller animated:YES];
}

MFMailComposeViewController is not interactive

I'm using the following code in two view controllers; one, where it is triggered by pressing a button, and another, where it is triggered by tapping a table cell. In the first, it works fine.
In the second, triggered by the table-cell tap, the mail composer appears, with the fields correctly filled out, but the cursor and keyboard do not appear, so you can't actually enter anything into the mail message. (You can hit Cancel or Send without problems.) Any idea what's wrong? Thanks!
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"Message subject"];
[picker setMessageBody:#"Sample message" isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
} else {
NSLog(#"cant send mail");
}
I figured out the problem, but it's absolutely ridiculous -- probably a bug in the SDK. I was presenting the problem UIViewController with a UIModalTransitionStyleFlipHorizontal, while I was presenting the healthy UIViewController with the default transition style. Something about the UIModalTransitionStyleFlipHorizontal seems to make the presented view controller greedy to be first-responder; it won't give up first-responder status to the launched MFMailComposeViewController.

iphone - adding the view of MFMailComposeViewController (in-app email)

I've spent the past two days just trying to enable the sending of email from within my app. Hoping one of the smart folks on here can help me out.
presentModalViewController doesn't work for me (just crashes the app with no explanation as to why), so I'm forced to add the view of MFMailComposeViewController. Here's my attempt:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:#"test subject"];
[controller setMessageBody:#"this is the message body" isHTML:NO];
// [self presentModalViewController:controller animated:YES]; //this crashes the app
//so I try this instead:
controller.view.frame = CGRectMake(0,0,480,320);
[self.view addSubview:controller.view];
[controller release];
What gets added to the screen is the subject bar only, with cancel and send buttons. None of the text fields (To:, Cc:, Subject, body) are displayed. Why aren't they a part of MFMailComposeViewController's view, and how can I display them?
Honestly, you should be using presentModalViewController. Rather than force your way around the SDK, consider debugging the crash. Turn on the debugger and see if there are any exceptions logged in the console. Check for crash logs, etc...
Also, make sure that self is a proper delegate and a UIViewController subclass.
I 've solved this problem:
try NOT this:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
but THIS:
MFMailComposeViewController *mailComposeViewController = [MFMailComposeViewController new];
You should instead try:
[[self navigationController] presentModalViewController...];
Since that's the proper way to present it. Trying to add its view manually is unfortunately utterly incorrect and will never work.
Well I have determined that one must create a dummy view controller otherwise the darn thing won't slide in.
I create a class called Sys_Mail that is a #interface Sys_Mail : UIViewController <MFMailComposeViewControllerDelegate>
and then i create basically a root view view controller. I wrestled with portrait/landscape for hours but determined that if you attach the view controller to the top level view (which contains my landscape transform) then it slides in as a landscape window. There is just one visual glitch, the parent window gets moved around for a few seconds while the new window slides in, this is a side effect of the landscape transform doing odd things to the parent....
in order to get landscape orientation on the sliding window you must declare a method in your Sys_Mail class that handles the autorotate message:
//=======================
// shouldAutorotateToInterfaceOrientation
//=======================
// see if this ever gets called for the view controller
-(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
if (TRACE) printf ("shouldAutorotateToInterfaceOrientation\n");
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); // or whatever orientation is needed
}
the variable gMasterView refers to my top level view (that has the landscape transform and is attached to the window). Subviews don't seem to work, view controllers are awful THEY ARE MORE DESIGN PATTERN CRAP. I want total control of my views not some microsoft MFC type crud!
Sys_Mail* g_root_vc;
if (g_root_vc == nil) {
// create an empty view controller so we have something to work with
g_root_vc = [[Sys_Mail alloc] init];
g_root_vc.view = (UIView*) gMasterView;
}
so this
I have the same crash and finally I can fix it by sending presentModalViewController message to [self navigationController].
Here is my code:
// Create the Mail composer view controller
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
// Set the view controller delegate
controller.mailComposeDelegate = self;
// Set recipients, if you want
[controller setToRecipients:recipients];
// Set subject, if you want
[controller setSubject:#"The subject"];
// Set message body, if you want
[controller setMessageBody:#"The message body" isHTML:YES]; // isHTML -> YES/NO depending the message body
// Present the view controller
[[self navigationController] presentModalViewController:controller animated:YES];
// Memory management
[controller release];
I hope this can help!