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).
the problem is that when I load the controller, the screen becomes black as you can see from the image...
http://desmond.imageshack.us/Himg211/scaled.php?server=211&filename=schermata092456187alle1.png&res=landing
this is the code:
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObject:#"123456789"]; // your recipient number or self for testing
picker.body = #"test";
[self presentModalViewController:picker animated:YES];
Testing the MFMessageComposeViewController is currently not supported in the simulator. The MFMailComposeViewController is though.
Try out your code on an actual device and it will work.
Related
How can i display the background of the NavigationController (including title/buttons) in my UIPopovercontroller on the iPhone?
At the moment it looks like that:
In my PopoverView-ViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = NO;
self.navigationController.navigationBarHidden = NO;
self.navigationItem.title = #"self.navigationItem.title";
}
When calling Popover:
InfoView *iv = [[InfoView alloc] initWithNibName:#"InfoView" bundle:nil];
UINavigationController *uc = [[UINavigationController alloc] initWithRootViewController:iv];
self.pop = [[UIPopoverController alloc] initWithContentViewController:uc];
[self.pop setDelegate:self];
[self.pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:true];
It should look like this:
At first UINavigationController doesn't have own background, it shows background of content view controller. If you can show popover with navigation controller successfully, then check your InfoView. Does it's view has some background?
Second, I tried to execute your code multiple times in different configurations on iPhone, but always have received error
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIPopoverController
initWithContentViewController:] called when not running under
UIUserInterfaceIdiomPad.
And that was not surprise for me. Even if you could make it work, then Apple may reject your application.
2.1 Apps that crash will be rejected - Just test your code on several devices and see result.
your code
InfoView *iv = [[InfoView alloc] initWithNibName:#"InfoView" bundle:nil];
UINavigationController *uc = [[UINavigationController alloc] initWithRootViewController:iv];
self.pop = [[UIPopoverController alloc] initWithContentViewController:uc];
[self.pop setDelegate:self];
[self.pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:true];
is perfect just hide the default navigation controller and add a navigationBar in the XIB of InfoView.xib and write the cancelButtonAction there to perform the dismissal of the view or the detail of the tableview selection. It Works fine, Please check the image i have done the same way, and believe me it works fine.
Add this to your code before the line [self.pop presentPopoverFromBarButtonItem:se..:
uc.modalPresentationStyle = UIModalPresentationCurrentContext;
See the documentation for the modalPresentationStyle property.
I think you'll need to paste in more of the code for your InfoView controller, as I suspect that's where the problem is.
Have you tried setting up your background view as a class?
[pop setPopoverBackgroundViewClass:bgView];
I want to create a simliar effect for ipad in xcode as shown in following link, can any one guide.
http://tutorials.flashmymind.com/2009/04/flash-mouse-trailer-with-stars/
-(IBAction)SendEmail{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"Hello from xCode!"];
Regards.
Mouse trails don't even make sense on an iPad. There is no cursor.
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.
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];
}
I have an iPhone app which hides the status bar when run. After launching a MFMessageComposeViewController and dismissing it (after either send or cancel) all my previously drawn elements are shifted down 20px. This is clearly to do with the status bar showing when the MFMessageComposeViewController is presented.
Can I either stop this happening or fix it in my (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result method to undo the change?
Thanks :)
OK, turned out I needed to set:
self.wantsFullScreenLayout = YES;
in my view controller. this fixed it. perhaps it's useful to someone else.
After I launch the modal view picker is when I remove the status bar.
You may need to set it to NO when you return.
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.wantsFullScreenLayout = NO;
NSString * currentString = nil;
currentString = [[NSString alloc] initWithFormat:#"Just a Test (iPhone/iPod/iPad)." ];
picker.body = currentString;
[self presentModalViewController:picker animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];