MFMessageComposeViewController bar transparent - ios

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.

Related

CNContactViewController navigation bar background color is not matching with my app

I am using CNContactViewController form contact framework for adding new local contact, but after presenting this view controller navigation bar becomes some different color which is not matching in my app. below is the code and i am adding screenshot too for reference.
please suggest me a way to customize this navigation bar.
CNContactStore *store = [[CNContactStore alloc] init];
CNMutableContact *contact = [[CNMutableContact alloc] init];
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:contact];
controller.contactStore = store;
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
You can set in AppDelegate didFinishLaunching the bar tint color for all navigation bar instances of your app (CNContactViewController including) using:
[[UINavigationBar appearance] setBarTintColor: [UIColor ... yourColor]];

How to push a new viewController with Transparent Background?

I wanted to Push New View Controller with Transparent Background on top of one View Controller which is already shown. I know How to PRESENT but I wanted to PUSH new View Controller.
UIViewController *controller = [[UIViewController alloc] init];
self.definesPresentationContext = YES;
controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:controller animated:YES completion:^{}];
You need to give memory to your ViewController and set to RootController of UINavigationController. After that, you can push it from your current controller...
UIViewController *yourViewController = [[UIViewController alloc] init];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:yourViewController];
[self presentViewController:navigationController1 animated:YES completion:nil];

presenting a view controller

I want to go to a view controller when the button "Cancel" is pressed. I tried using this method but when I click 'Cancel", it just displays a black screen. I am a beginner at IOS.
-(void) cancelButtonPressed {
homeView = (HomeViewController *)[[UIViewController alloc]init];
[self presentViewController:homeView animated:YES completion:nil];
}
EDITED FOR COMMENTS:
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]initWithTitle:#"Cancel" style:UIBarButtonItemStylePlain target:self action:#selector(cancelButtonPressed)];
self.navigationItem.leftBarButtonItem = cancelButton;
Try doing this:
HomeViewController *homeView = [[HomeViewController alloc]init];
[self presentViewController:homeView animated:YES completion:nil];
Also note that black is the default colour of the window. If you don't have any view controller named HomeViewController, and you present it, by default it will be visible as black colour to the user.
To Avoid this, you need to set the View for the newly presented view controller, which you can access by homeView.view
If you are using storyboard, then use storyboard ID:
HomeViewController *homeView = [self.storyboard instantiateViewControllerWithIdentifier:#"HomeViewController"];
[self presentViewController:homeView animated:YES completion:nil];

Graphic issue presenting MFMessageComposeViewController

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];

Apple's controllers not presenting properly in iOS7

In my iOS app i present standerd controllers MFMessageComposeViewController and UIImagePickerController.
But they both presenting with strange navigation bar.
How can i fix this problem?
UPD code for presenting controllers
UIImagePickerController:
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = sourceType;
cameraUI.allowsEditing = YES;
cameraUI.delegate = self;
[self presentViewController:cameraUI animated:YES completion:nil];
MFMessageComposeViewController:
MFMessageComposeViewController *messageViewController = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]) {
messageViewController.view.backgroundColor = [UIColor whiteColor];
messageViewController.messageComposeDelegate = self;
recipient= [NSStringMask maskString:recipient withPattern:#"\\+(\\d{1}) \\((\\d{3})\\) (\\d{3})-(\\d{2})-(\\d{2})"];
messageViewController.recipients = #[recipient];
messageViewController.body = body;
[self presentViewController:messageViewController animated:YES completion:nil];
}
In iOS 7, the status bar and the navigation is translucent by default. To make the view act 'normal' like in iOS 6. you need to add this to the controller you are presenting.
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
If you want to read up more about changes in views. Check out this post. I find it a nice quick overview whats changed.
http://www.brianjcoleman.com/ios7-weve-got-a-problem/
See this question. I used the second answer, though I suspect the first would work for me also.

Resources