UINavigation Bar changing tint after using UIImagePickerController - ios

I have a app that can attach a photo to an NSAttributedString in a textView. The UI design has a blue-grey navigation bar with white text.
However, after I use the UIImagePicker, the tint of the NavigationController changes to black text.
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
_imagePickerController = [[UIImagePickerController alloc] init];
_imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
_imagePickerController.sourceType = sourceType;
_imagePickerController.delegate = self;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
_imagePickerController.showsCameraControls = YES;
}
[self presentViewController:_imagePickerController animated:YES completion:nil];
}
I'd post an image of the view before launching the UIImagePicker but I don't have enough reputation points (and I don't really know how to get them either).
And I'd post the image after launching the image picker and picking one and returning from the UIImagePicker, but again, not enough reputation points.
Anyone have any ideas if this is 'normal' or a bug ion iOS? Any suggestions on a workaround?
P.S. If you want to see the images, I can email them to you. Any advice is appreciated.

This indeed seems to be a bug, and has been present since iOS 7 beta 6 (or earlier).
There is another SO post about this with some solutions: UIImagePickerController breaks status bar appearance

This problem can be avoided by changing picker's modal presentation class to be different than full screen (e.g. UIModalPresentationPageSheet)
Code:
imagePickerController.modalPresentationStyle = UIModalPresentationPageSheet;

Related

Taking Photos in landscape having issues in my iOS application

I take photos using UIImagePickerController, source type is UIImagePickerControllerSourceTypeCamera.
After i captured, the image editing is changing depending upon the orientation. Herewith i attached my snapshot.
Image 1 : i took this image in portrait mode.
Image 2 : i took this image in landscape mode. here, the top portion is in black color.
My code is :
UIImagePickerController *pickerCamera = [[UIImagePickerController alloc] init];
pickerCamera.delegate = self;
pickerCamera.allowsEditing = YES;
pickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:pickerCamera animated:YES completion:NULL];
I want to rotate the image to portrait. Please help me to solve this issue.

Camera Preview not filling iPad screen in Landscape

My app is iPad only, and supports only Landscape View.
I have a UIImagePickerController which loads the Camera.
I set it up with the following code:
m_Pickercontroller=[[UIImagePickerController alloc] init ];
m_Pickercontroller.sourceType = UIImagePickerControllerSourceTypeCamera;
m_Pickercontroller.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
m_Pickercontroller.cameraDevice = UIImagePickerControllerCameraDeviceRear;
m_Pickercontroller.showsCameraControls = YES;
m_Pickercontroller.navigationBarHidden = YES;
m_Pickercontroller.toolbarHidden = YES;
m_Pickercontroller.wantsFullScreenLayout = YES;
m_Pickercontroller.allowsEditing=NO;
It is presented with [self presentViewController:m_Pickercontroller animated:YES completion:nil]; I have also tried with a Modal and get the same result.
This occurs on first open of the view only. If you reopen the camera or retake the picture, it goes away.
I have also tried setting the m_Pickercontroller frame size, both before and after it is loaded.
Here is what it looks like, black area is empty, white area is the camera preview. Ignore the white line overlay, that is part of the app.
Ok, so this makes no since whatsoever but what was causing this was the animation:yes
I changed [self presentViewController:m_Pickercontroller animated:YES completion:nil]
to [self presentViewController:m_Pickercontroller animated:NO completion:nil]
and this issue has fixed itself. apparently iOS does not resize the camera preview after animating the view in.

Using a toolbar with buttons as an imagepicker camera overlay?

I am trying to add some basic functionality to a camera application.
The app works like this: You press the camera button somewhere in the app, the camera activates and then gives you some extra basic functionality aside from the flash, switchcameras, cancel and take picture buttons.
Having clicked through quite a bit of search results it seems like only a new cameraoverlay is possible.
Now, I've managed to show some text or a button on itsself somewhere on the camera screen following the scanning example on musicalgeometry.com.
But what I'm trying to do here is add an entire view, constructed in IB, as a cameraOverlay. (for example just a toolbar with some buttons and the rest is blank).
Can I use storyboards for this or is this easier working with Nib files?
Or can the toolbar be programmatically added to a UIView so it can serve as cameraOverlay?
I would think the latter (programmatically) is the most straight forward but I haven't been able to find any examples for either possible solution so anything is welcome.
This is the basic overlay code from the example:
- (void) viewDidAppear:(BOOL)animated {
OverlayView *overlay =
[[OverlayView alloc] initWithFrame:CGRectMake(
0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
// Create a new image picker instance:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// Set the image picker source:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hide the controls:
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
// Make camera view full screen:
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform,
CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
// Insert the overlay:
picker.cameraOverlayView = overlay;
// Show the picker:
[self presentModalViewController:picker animated:YES];
[picker release];
[super viewDidAppear:YES];
}

How to remove square ratio cropping for images on IOS

I am using the IOS standard image cropping functionality (move and scale) to crop my image before submitting it to the server.
However, I realize that the cropping provided has a square ratio (see screenshot below)
Snippet of the code is as follows:
//set up image picker
self.imgPicker = [[[UIImagePickerController alloc] init]autorelease];
self.imgPicker.allowsEditing = YES;
self.imgPicker.delegate = self;
//Trigger get photo from library function
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.imgPicker animated:YES];
How can allow 'move and scale' editing and at the same time allow the user to do cropping WITHOUT the square ratio restriction?
I think you need change self.imgPicker.allowsEditing = YES; to self.imgPicker.allowsEditing = NO;
This library can help you.
https://github.com/gekitz/GKImagePicker
It supports custom cropping and it's easy to integrate with the native picker if needed.
I think , this will serve your purpose . You can change the constraints as you want
https://github.com/kishikawakatsumi/PEPhotoCropEditor?source=cc

Custom tab bar background image - in iOS 4.x

I have made a tab bar iOS project, when I received the request to change the tab bar's background image to a custom image. The project is developed for iOS 4.x, so the iOS5's
[tabBar setTabBarBackgroundImage:[UIImage imageNamed:#"custom.jpg"]] does not work. Can you suggest me some simple solutions (if there is any possibility, I would not like to change the entire project)?
Edit:
Only three lines of code can resolve all:
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"customImage.png"]];
[self.tabBarController.tabBar insertSubview:imageView atIndex:0];
[imageView release];
A possible solution would be to put an UIView with your background image exactly behind the UITabBar. Then lower the opacity of your tabbar to 0.5 so you can see the background-image coming through.
UIView *bckgrndView = [[UIView alloc] initWithFrame:CGRectMake(tabbar.frame.coords.x, tabbar.frame.coords.y, tabbar.frame.size.width, tabbar.frame.size.height)];
[bckgrndView setBackgroundImage:[UIImage imageNamed:#"custom.jpg"]];
[tabbar.superView insertSubView:bckgrndView belowSubview:tabbar];
tabbar.alpha = 0.5;
[bckgrndView release];
Sorry if my code contains some errors. I tried doing this by heart... But you'll catch the drift.
I have answered similar kind of question here. Hope it will help.
Check out NGTabBarController, an open source tab bar replacement with customizable background image.

Resources