Graphic issue presenting MFMessageComposeViewController - ios

I've this strange issue when i'm presenting a MFMessageComposeViewController in my app!
I don't know what this black bar is and i'm unable to remove the app logo from the NavigationBar.
And here is the code for presenting the controller
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
[[messageController navigationBar] setBarTintColor:SMAN_ORANGE_COLOR];
[[messageController navigationBar] setTintColor:[UIColor whiteColor]];
messageController.messageComposeDelegate = self;
[messageController setRecipients:recipents];
[messageController setBody:message];
// Present message view controller on screen
[self presentViewController:messageController animated:YES completion:nil];

To remove the app logo, try to add in your method above the following code:
messageController.navigationItem.titleView = [UIImageView new];
To change the Status Bar style (White Color) add the following code before presenting the messageController:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
Also in your .plist file set:
View controller-based status bar appearance to NO

I solve the issue subclassing my UINavigationController and changing the appearance of it with [UINavigationBar appearanceWhenContainedIn:[myNavControllerSubclass class], nil]

[self presentViewController:messageController animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
}];
this works in ios 8 for the white status bar
Refer answer #1 also.

As per Apple's documentation you can only present it modally.
[self presentModalViewController:messageController animated:YES];

Related

iOS - Dismiss RootViewController

I have a code like this to present a TOWebViewController that contain URL to my company web page.
TOWebViewController *webViewController = [[TOWebViewController alloc] initWithURL:url];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:webViewController];
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:navigationController];
After its open how I get back to my previous view or dismiss the root view controller since my navigator bar only show grey bar.
thanks
Use [self presentViewController:imagePickerController animated:YES completion:nil]; instead.And don't use root view controller!
you need to create a custom back button #selector and in it you need to set [[[[UIApplication sharedApplication] delegate] window] setRootViewController:previousViewController];
though you need the reference of your previous viewController, however i won't recommend this approach.As #lumialxk said, use this instead [self presentViewController:imagePickerController animated:YES completion:nil];

MFMessageComposeViewController bar transparent

I'm trying to present a MFMessageComposeViewController modally.
MFMessageComposeViewController *controller =[[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = #"Welcome to my app!";
controller.recipients = [NSArray arrayWithObjects:#"99999999", nil];
controller.messageComposeDelegate = self;
[self presentViewController:controller
animated:TRUE
completion:nil];
}
The navigation bar of the MFMessageComposeViewController appears transparent.
The controller is appearing like this:
Any ideas how to fix this?
Thanks,
Daniel
You've made changes to the navigation bar using the appearance proxy. Either revert those changes, or override them directly on MFMessageComposeViewController's navigation bar.

iMessages change text color

My app is showing iMessages ViewController via UIActivityController. However, the colors of labels are all messed up (blue so they are barely visible). I think this is because the view controller is using my app's tint color. See below.
How can i fix this?
thanks!
I ran into something similar with presenting MFMailComposerViewController modally. Try setting the appearance of your app's tint color to nil when presenting the activity controller, and then back to your desired app tint when it completes. Here's what I did with MFMailComposer. You should be able to modify for your activity controller:
...
[[UINavigationBar appearance] setBarTintColor:nil]; // Set to default before presenting
MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init];
mailVC.mailComposeDelegate = self;
[self.navigationController presentViewController:mailVC animated:YES completion:nil];
...
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[[UINavigationBar appearance] setBarTintColor:MyAppsCustomColor]; // set it back when finished
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
EDIT
When I use this solution, it changes the nav bar appearance in the presented modal that is selected in the activity view controller (messages, mail, etc). I'm setting my app's nav bar appearance to blue in my delegate, and then back to blue in the completion block. The app's nav bar remains blue, and the presented messages/mail modal is shown with the default light gray nav bar.
UIActivityViewController* avc =
[[UIActivityViewController alloc] initWithActivityItems:#[#""]
applicationActivities:nil];
avc.completionHandler = ^(NSString *activityType, BOOL completed) {
// ...
dispatch_async(dispatch_get_main_queue(), ^{
// Set tint color back to blue.
// This block is executed whether the user finishes or cancels.
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
[[self navigationController] setNeedsStatusBarAppearanceUpdate];
});
};
[[UINavigationBar appearance] setBarTintColor:nil];
[self presentViewController:avc animated:YES completion:nil];

MailComposeViewController does not keep status bar style [duplicate]

This question already has answers here:
MFMailComposeViewController in iOS 7 statusbar are black
(13 answers)
Closed 3 years ago.
I'm having an issue with the navigation Bar in MFMailComposeViewController.
I have an app where we set the "Status bar style" to "UIStatusBarStyleLightContent" in the plist file. It works perfectly in all views except when I call up MFMailComposeViewController. It goes back to black. The rest is ok. We have a custom image that does carry forward, and I can set the tint color with no problems. Any one know how to fix this? How to reset the "Status bar style" to "UIStatusBarStyleLightContent" in mail?
in AppDelegate
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"headerLogo.png"] forBarMetrics:UIBarMetricsDefault];
calling mail
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[[mailController navigationBar] setTintColor:[UIColor whiteColor]];
[[mailController navigationBar] setBarTintColor:[UIColor whiteColor]];
[self presentViewController:mailController animated:YES completion:nil];
I believe setting the barStyle in MFMailViewController is something that is not accessible unless because of private API in Apple's code. The reason why you're able to set the UINavigationBar to a certain picture in the app delegate is because in the app delegate, you are calling to the appearance of the UINavigationBar class instead of the tint color of the MFMailViewController's navigation bar.
Hope this helps
In the info.plist add new row:
UIViewControllerBasedStatusBarAppearance
Set it to:
NO
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
[self presentViewController: mail animated: YES completion: ^ {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}];

Any way to present navigation bar for UIImagePickerController, source type UIImagePickerControllerSourceTypeCamera, in iOS 7?

In iOS 6, I was using the following code to push a UIImagePickerController, of source type UIImagePickerControllerSourceTypeCamera, and to show its navigation bar. I wanted to show the navigation bar because after taking the image, I'm pushing another VC that allows the user to set some attributes in the database.
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
cameraController = [[UIImagePickerController alloc] init];
cameraController.delegate = self;
cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:cameraController animated:YES completion:NULL];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
cameraController.topViewController.title = #"Add";
cameraController.navigationBar.translucent = NO;
cameraController.navigationBar.barStyle = UIBarStyleDefault;
[cameraController setNavigationBarHidden:NO animated:NO];
}
In iOS 7 this code no longer shows the navigation bar. Does anyone know if there's a way to to get the navigation bar back for UIImagePickerController, of source type UIImagePickerControllerSourceTypeCamera?
Guess what? When imagePicker presents, it's automatic set to hidden....
All you need to do is setHidden:NO in next runloop. Like:
[self presentModalViewController:imagePicker animated:YES];
[self performSelector:#selector(showNavigationBar:) withObject:imagePicker afterDelay:0];
- (void)showNavigationBar:(UIImagePickerController*)imagePicker {
[imagePicker setNavigationBarHidden:NO];
}
#LeverkusenFan's solution works well. But instead of using a hack such as a run loop, you use the completion handler of presentViewController to achieve that effect.
[self presentViewController:cameraController animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
cameraController.topViewController.title = #"Add";
cameraController.navigationBar.translucent = NO;
cameraController.navigationBar.barStyle = UIBarStyleDefault;
[cameraController setNavigationBarHidden:NO animated:NO];
}];
In fact a better solution that avoids the weird animation when the navigation bar shows up and which works well when you press the back button on the nav bar is as follows:
In the delegate for the UIImagePickerController implement the following function.
- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (navigationController == self.cameraController && navigationController.viewControllers.count == 1) {
// When showing the ImagePicker update the status bar and nav bar properties.
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
navigationController.topViewController.title = self.cameraTitle;
navigationController.navigationBar.translucent = NO;
navigationController.navigationBar.barStyle = UIBarStyleDefault;
[navigationController setNavigationBarHidden:NO animated:animated];
}
}
This function will get called when the ImagePicker is shown and we only make the changes for the rootViewController of the ImagePicker (i.e. the camera screen).

Resources