I'm developing a messaging app (something like WhatsApp), users can send text and image messages to one another.
when user wants to send an image, he can choose one from the camera roll or he can take one with the camera.
This is how I present the UIImagePickerController
for both cases:
- (void)handleTakePhoto
{
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:ipc animated:YES];
[ipc release];
}
- (void)handleChooseFromLibrary
{
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
NSString *desired = (NSString *)kUTTypeImage;
if ([[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary] containsObject:desired]) {
ipc.mediaTypes = [NSArray arrayWithObject:desired];
}
[self presentModalViewController:ipc animated:YES];
[ipc release];
}
After the user choose/take a picture I'm pushing a SendImageViewController
that shows the image in full screen and has a button to actually send the image.
This is how I push it:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
SendImageViewController *sivc = [[SendImageViewController alloc] initWithImage:image
delegate:self];
[picker pushViewController:sivc animated:YES];
[sivc release];
}
When I push SendImageViewController
from the camera roll everything works great.
The problem is that I can't push my SendImageViewController
when the image is taken from the camera, because the camera doesn't have a navigation bar (I tried to push it but my SendImageViewController
view doesn't presented well)
How can I deal with this?
* I don't want to dismiss the picker and then push the SendImageViewController
, I want that the SendImageViewController
will be pushed on top of the camera/camera roll, so when I tap the back button I'll back to the camera/camera roll view.
Try showing the navigation bar like this :
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
[picker setNavigationBarHidden:NO animated:YES];
[picker pushViewController:vc animated:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With