Taking photos using the Iphone camera - iphone

We have developed an iPhone app and now wish to utlise the camera to:-
- take a photograph and save it in a specific sub-directory (set up when the App is upgraded/loaded) of Photos but only when the photo is taken from within the app. All other photos should go to the standard photo folder. Is this possible and how can we do it?
- We would like to reference these photos so that pressing a link within the app history accesses that specific photo. Other photos are referenced elsewhere in the app history. Again is this possible and how can we do it?

- (IBAction) buttonname
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)UIPicker didFinishPickingImage:(UIImage *)info editingInfo:(NSDictionary *)dictionary
{
[UIPicker dismissModalViewControllerAnimated:YES];
imageview.image=info;
}

Related

How to force camera to take squared pictures in iOS 7

In iOS 7 the camera comes with several modes: video, photo, square and pano. In the application I am developing, we allow users to use the camera to take pictures. We only want squared pictures so we make users crop images afterwards.
Is it possible to programmatically force the camera to only take squared pictures?
This is my code to open the camera:
-(void) openImagePickerSource:(UIImagePickerControllerSourceType)type
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = type;
[self presentViewController:imagePicker animated:YES completion:^{}];
}
I have been looking at the documentation but didn't find anything.
UIImagePickerController has a property called 'allowsEditing'. That will open the Camera in full screen and allows you to resize the taken photo after shot.
imagePicker.allowsEditing = YES;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
you can get the photo in the protocol method using a key 'UIImagePickerControllerEditedImage'.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *pic = (UIImage *)[info objectForKey:UIImagePickerControllerEditedImage];
}

How to access camera of iPhone using phonegap app

I have a simple application developed for android which takes a photo, accessing the camera of device.
I want the same application to be run on iPhone. For android we write permissions for accessing camera in manifest file. How do you access the camera in iPhone. Where do we need to set up it. Can anyone please help me?
Thanks in advance
Use the Media Capture API in the latest code, or wait for 0.9.6:
http://docs.phonegap.com/phonegap_media_capture_capture.md.html
For accessing the camera in iPhone, you can use following code.
// Camera
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.allowsImageEditing = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
//[self presentModalViewController:imgPicker animated:YES];
[objParent presentModalViewController:imgPicker animated:YES];
[imgPicker release];
Let me know in case of any difficulty.
Below are the delegate method for camera.
Delegate Name: UIImagePickerControllerDelegate, UINavigationControllerDelegate
Methods:
#pragma mark UIImagePickerController delegate
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *imgCapturePhoto = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
[imgPhoto setImage:imgCapturePhoto];
[self dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
[picker dismissModalViewControllerAnimated:YES];
}
Cheers

how do I implement "Choose Existing Photo" in my app like in default iphone phonebook?

I want to develop an app which has functionality same as iphone phonebook capturing image and choosing iamge,
what should I to use for doing such
I have made an UIImageView and a button for UIActionSheet,
now I want to perform "Take Photo" and "Choose Existing Photo" options in my app
help me out, I do appreciate
thanks in advance ....
Hey #Veer you need to use UIImagePickerController
check out the documentation
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
and check out this link
http://iphone.zcentric.com/2008/08/28/using-a-uiimagepickercontroller/
It has sample examples about the same.
Edit you can use these methods to get the image in you UIImageView object
- (void)selectPhotos
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
imageView.image = image;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}

Record Video/Take Picture switch in iPhone app?

So i got a iphone app that is a button and when you pressed it i want the camera view to pop up and i want to give the user a choice to take a picture or a video like in the default camera app the one switch thing.
Thanks!
What you are looking for is something called 'UIImagePickerController'
-(void) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
This method is the what would be called when you press your button(s), what i am doing here is I have two buttons, choosePhotoBtn, and takePhotoBtn, the both link to the same method.
If the button that was pressed (the sender) is choosePhotoBtn, then UIImagePickerControllerSourceTypeSavedPhotosAlbum is set as the UIImagePickerController's source type.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
bannerImage.image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}
These two methods are delegate methods. They get called when the modelViewController holding the UIImagePickerController is dismissed.
I would recommend this site, as it has a brilliant tutorial on how to use these functions.
http://icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/
This is where i learnt how to use these classes, it seems like the site has had a wordpress comment attack on it at the moment, and firefox is blocking it for me, but if u can get to the page. Its a great resource.

UIImagePicker not showing Original Image from Photos Library in OS 3.1.2

Holy Crap! Really... I'm frustrated with this problem that get me stuck with my apps for a week now.
Here is the code
- (IBAction)loadTheImage {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}
If I set the source as SavedPhotosAlbum (Camera Roll), then it works OK. But when I set it to PhotoLibrary, it just returns nil. And this just happens in OS3.1.2. In OS4 it works OK (ie returns the original image just fine).
Anybody?
A given source may not always be available on every device. This could be because the source is not physically present or because it cannot currently be accessed.
Before attempting to use an UIImagePickerController object to pick an image, you must call [UIImagePickerController isSourceTypeAvailable:] method to ensure that the desired source type is available.