Open camera view upon app Startup (iOS6) - iphone

what im trying to do is to have the app open up with the camera as the first screen. It isn't working and i don't know what im missing. If anyone can fill me in that would be wonderful... Thanks.
- (void)viewDidLoad
{
[super viewDidLoad];
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
}

Try like that. Hope it helps you:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];

Related

UIImagePickerControllerSourceTypePhotoLibrary in iOS 7 is not Working

When I upgraded to iOS7, my app is showing an empty view controller when I access the photo Library from the application. It was working with older frameworks.
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.delegate = self;
self.imagePicker = imagePickerController;
//self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:self.imagePicker animated:YES completion:nil];
Please apply direct this code
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
when this code run then "application" Would like to access your photos message come when you click on OK then all images will be displayed
Thanks.

title and description for camera click images

In my camera app i want when i click an image it will ask for title and description from the user and then save it.right now its saving images but not asking for title and description.I am new to iOS.so,may be this is a silly question.please help me to get this.for camera click i am using this method:-
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
BOOL camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if(camera)
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[[picker navigationBar]setBarStyle:UIBarStyleDefault];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[picker setDelegate:self];
[self presentViewController:picker animated:YES completion:NULL];
[picker release];
}
You can do it in the following way:
Click the image using camera.
Come back to your app without saving the image. You'll have a reference of the image clicked in your application till now.
ask the user for the title & description.
Save the image to picture library using this line of code:
UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void contextInfo);
Hope it helps you.
More Help Here....
For me this tutorial guided me to achieve what i want.So, i think to share the link.May be someone gets benefited.
http://www.raywenderlich.com/13541/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-22
and this piece of code helps me out..
-(void) takePhoto{
BOOL camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if(camera)
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[[picker navigationBar]setBarStyle:UIBarStyleDefault];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[picker setDelegate:self];
[self presentViewController:picker animated:YES completion:NULL];
[picker release];
actionSheetbool = false;
}
else
{
UIAlertView* cameraAlert = [[UIAlertView alloc]initWithTitle:#"Sorry!!" message:#"Camera not found." delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[cameraAlert show];
[cameraAlert release];
}
}
-(void)photoLibrary{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
[imagePicker release];
actionSheetbool = false;
}
}

How to set Custom overlay view on Editing View of UIImagePickerController?

All
I have create UIImagePickerController with delegate and picking images from PhotoLibrary.
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self presentModalViewController:imagePicker animated:YES];
And when application reach to Editing view of UIImagePickerController i set one Overlay view and create two buttons for it.
Cancel and Choose
On Cancel Button click
[imagePicker popToViewController:[currentViewController.viewControllers objectAtIndex:1] animated:YES];
this cod work fine..
But choose Button does not working,
if i set code like here,
[self imagePickerController:imagePicker didFinishPickingMediaWithInfo:[imagePicker mediaTypes]];
than it returns NULL value of info dictionary.
Is that any other way to set overlay view on Editing ImagePicker ?
Regards,
try this code
CustomOverlayView *CustomOverlayView = [[CustomOverlayView alloc] initWithFrame:CGRectZero];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing = NO;
imagePickerController.delegate = self;
imagePickerController.showsCameraControls = YES;
[imagePickerController.view addSubview:CustomOverlayView];
[self presentModalViewController:imagePickerController animated:YES];
}

Issue with imagePicker

I've got a little tiny problem when i present a ImagePickerController..
Here is my code:
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.allowsEditing = NO;
imgPicker.delegate = self;
imgPicker.navigationBarHidden = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imgPicker animated:YES];
And this is what i see on my device:
We can see something which can be a navigationBar but i set it to HIDDEN and nothing change..
Anyone has an idea?

iPhone Video compression on/off

I have implemented video capturing by:
IImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:imagePicker.sourceType];
if ([sourceTypes containsObject:(NSString *)kUTTypeMovie ]){
imagePicker.mediaTypes = sourceTypes;
}
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
I can record video and send it to YouTube using YouTube API, but if the video length is more then about 5 minutes, and I click USE - the application is closed. But no problem appear if I select even 10 minutes video from library (i see "Compressing video" progress), video is saved to my view and uploaded to YouTube.
Can anybody tell me what the problem could be?
You used QualityTypeHigh with high resolution 1280x720. so it take so much memory.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[imagePicker setVideoQuality:UIImagePickerControllerQualityQualityTypeMedium];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
[imagePicker setVideoMaximumDuration:30];
imagePicker.allowsEditing = YES;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];