if UIImagePickerControllerSourceTypePhotoLibrary allowsediting NO - iphone

When I use allowsEditing = NO on the camera it works fine.
Works:
if( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
if(imagePicker == nil) imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
But if I try to put it on the photo library I still get allowsEditing YES.
Don't work:
if( [UIImagePickerController UIImagePickerControllerSourceTypePhotoLibrary])
{
if(imagePicker == nil) imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
Any ideas?

picker.allowsEditing = YES;
picker.delegate = self;

Related

Camera sometimes displaying black screen

I am accessing default camera in my app.Sometimes it is displaying black screen.What is the solution for this problem?.
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
// imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
imgPicker.allowsEditing = NO;
imgPicker.showsCameraControls = NO;
cameraView.backgroundColor = [UIColor clearColor];
imgPicker.cameraOverlayView = cameraView;
[self presentModalViewController:imgPicker animated:YES];
}
I think the issue is with the way you present the UIImagePickerController instance:
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
// [picker release];

how to capture video

How can i record video
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing = YES;
imagePickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
i tried this one but i am getting image capture and i am not getting video capture.
#import <MobileCoreServices/UTCoreTypes.h>
-(void)actionStartVideoRecord:(id)sender {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
return;
}
UIImagePickerController* imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.videoQuality = UIImagePickerControllerQualityTypeHigh;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mType = [info valueForKey:UIImagePickerControllerMediaType];
if([mType isEqualToString:#"public.movie"]){
[NSData dataWithContentsOfURL:[info objectForKey:#"UIImagePickerControllerMediaURL"]]
}
}
Once the imagePickerController is presented, start the videoCapture of the device.
For more info, see doc for UIImagePickerController
You can make a subclass of UIImagePickerController. There you can have a UIButton. On tapping that, you could start capturing the video.

Setting flash mode to off as default

I'm trying to set the camera flash mode in an UIImagePickerController to off, but I don't understand the reference page. Here is my code:
- (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType {
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
if ([UIImagePickerController isSourceTypeAvailable:
sourceType] && [mediaTypes count] > 0) {
NSArray *mediaTypes = [UIImagePickerController
availableMediaTypesForSourceType:sourceType];
mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
UIImagePickerControllerCameraDevice *device;
picker.mediaTypes = mediaTypes;
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = sourceType;
[self presentModalViewController:picker animated:YES];
[picker release];
}}
I've tried setting picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff, but this results in an error. The reference page says that cameraDevice is a property. Does this mean that I need to create that property myself, or is it located somewhere? 'Cause the camera works if I don't do anything to the code, but with flash mode set to auto...
There is obviously something I haven't understood. :/
replace picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff with
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;

load the videos in ipod/iphone library but always crash

I hope to load the videos in ipod/iphone library like app 'videos'.
the codes show below, but it always cause crash
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
picker.sourceType= UIImagePickerControllerSourceTypePhotoLibrary;
picker.mediaTypes = [NSArray arrayWithObject:kUTTypeMovie];
picker.delegate = self;
Welcome any comment
Thanks
interdeb
We need to know how you are presenting it as well and perhaps information about the line it crashed on if it happens to be in your code. Here is an example that works for me:
- (void)presentVideoPicker:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = [self retain];
picker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeMovie, kUTTypeImage, nil];
picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
picker.allowsEditing = YES;
picker.sourceType = sourceType;
[self.view.window.rootViewController presentModalViewController:picker animated:YES];
[picker release];
}
I send it UIImagePickerControllerSourceTypeCamera or UIImagePickerControllerSourceTypePhotoLibrary

Can't display UIImage from UIImagePickerController when using IBAction

I 'm new to xcode. I try to select an image from the UIImagePickerController and
then display this image pressing a button. But the simulator crashes.
In the .h I use
UIImage *dispimage; //in order to make a global image
-(IBAction) open;
-(IBAction) print;
In the .m I have
- (void)viewDidLoad {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
dispimage = [info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissModalViewControllerAnimated:YES];
}
-(IBAction) open{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
};
-(IBAction) print{
imageView.image=dispimage;
};
When the button "print" is pressed, the sdk crashes. :(
Any help would be appreciated
Thanks in advance
Here is the code to get images from UIImagePickerController
-(void)viewDidLoad
{
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
dispimage = [[info objectForKey:UIImagePickerControllerOriginalImage]retain];
[picker dismissModalViewControllerAnimated:YES];
}
-(IBAction)open
{
if(self.imgPicker == nil)
{
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:self.imagePicker animated:YES];
[self.imagePicker release];
}
-(IBAction) print
{
if(dispimage != nil)
{
imageView.image=dispimage;
}
};