I want to choose video from PhotosAlbum, follows this code, NOW I can choose video but can not go delegate method:
imagePickerController:didFinishPickingMediaWithInfo:
I don't know why, any help is appreciated.
UIImagePickerController*m_pPickerController = [[UIImagePickerController alloc] init];
[m_pPickerController setEditing:NO];
m_pPickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
m_pPickerController.delegate = self;
m_pPickerController.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
m_pPickerController.delegate = self;
m_pPickerController.videoQuality=UIImagePickerControllerQualityTypeLow;
[self presentViewController:m_pPickerController animated:YES completion:^{
m_pPickerController.delegate = self;
}];
Related
This is an issue reported at crashlytics. I am getting this(I assume) when I load image picker and dismiss. I only got this once. But it got something to do with image picker or navigation controller. Does any one know the cause?
Update
Image picker camera is loaded like this.
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self;
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft)
{
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight] forKey:ORIENTATION_STRING];
} else {
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:ORIENTATION_STRING];
}
self.imagePickerController = imagePickerController;
[self.navigationController presentViewController:self.imagePickerController animated:YES completion:nil];
for other source types, I am using the following code.
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
popOver = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
self.imagePickerController = imagePickerController;
popOver.delegate = self;
CGRect popOverRect = sender.frame;
[popOver presentPopoverFromRect:popOverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
Add UIIMagePickerController to ContainerView. & then to view
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
[self addChildViewController:picker] ;
[picker didMoveToParentViewController:self] ;
[self.view addSubview:picker.view] ;
while removing pickercontroller do
[picker.view removeFromSuperview] ;
[picker removeFromParentViewController] ;
This code for capturing image one by one from camera,but after taking one image next time camera will open but with black screen(like it,s shutter close).all other ios version its working,but not working in ios 8.please tell me how can i solve it?
-(void)openCamera
{
if(![PickerHandler doesDeviceSupportMediaType:ITEM_TYPE_PHOTO])
{
[PickerHandler showNoDeviceSupportWarningForMediaType:ITEM_TYPE_PHOTO withDelegate:self];
}
else
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
[self presentViewController:picker animated:YES completion:nil];
}
}
Go to Settings > Privacy > Pictures ... and check if your app have permission.
In the code, use this to verify camera access.
- (BOOL)authorizedCameraAccess
{
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
return (status == AVAuthorizationStatusAuthorized);
}
this code is not work in simulator.
UIImagePickerController *videoScreen = [[UIImagePickerController alloc] init];
videoScreen.sourceType = UIImagePickerControllerSourceTypeCamera;
videoScreen.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
videoScreen.allowsEditing = NO;
videoScreen.delegate = self;
[self presentViewController:videoScreen animated: YES completion:NO];
Implement This method
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissViewControllerAnimated:NO completion:NO];
}
I am using the UIImagePickerController to let the user select a photo or video. The problem I am facing, is I use my own image editor for photo's so want allowsEditing=NO for photo's, but video must be a certain length so I want allowsEditing=YES for video.
Setting videoMaximumDuration for the image picker works fine when recording video, but if selecting from the camera roll it only informs the user that the video is too long if allowsEditing is enabled.
So far, I can successfully change the allowsEditing property when using the camera by listening for the ImageControlModeChanged notification. Then I can change the property using:
- (void)imageCaptured:(NSNotification *)notification
{
if (imagePicker.cameraCaptureMode == UIImagePickerControllerCameraCaptureModeVideo) {
imagePicker.allowsEditing = YES;
} else {
imagePicker.allowsEditing = NO;
}
}
However this doesn't work when selecting from the Camera roll. I have monitored the notifications and can't see one that would be useful to change the allowsEditing property depending on which item was selected.
Is this even possible?
Thanks
Why not creating 2 or even 4 UIImagePickerControllers instead of messing around with notifications?
- (void) useCamera
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (void) useCameraRoll
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (void)videoRoll
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = YES;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (void)vidCam
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
Edit:
After better understanding of the question I don't think it's possible. There are a few notification you can use but those are not documented anywhere or working on iOS7. If that is really the case the best solution I can think of is to use a 3rd party such as github.com/andrei200287/SAVideoRangeSlider and allowsEditing = NO for everything.
Simply allow editing on both image and video pick, but in didFinishPicking delegate method, for photo, choose original photo and not edited photo. However picker will still show that square box over image.
Try this
assign properties in view did load , not in imageCaptured method. it works fine
videoController.delegate = self;
videoController.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
videoController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:videoController.sourceType];
videoController.allowsEditing = YES;
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
This code make crash EXC_BAD_ACCESS on ios7 devices.
On iOS6 - all okay, and UIImagePickerControllerSourceTypePhotoLibrary work normal.
To work with camera
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
(NSString *) kUTTypeMovie, nil];
[self presentViewController:imagePickerController animated:YES completion:nil]; }
I want to display the saved videos in Photo Library in popOver controller just like images.
How can i show the videos in popOver controller?
My code for Images is as follow:
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
[popoverController release];
} else {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:imagePicker];
popoverController.delegate = self;
[self.popoverController presentPopoverFromRect:CGRectMake(100, 100, 150, 100) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[imagePicker release];
Help me to solve this problem.
Thank you,
You have to choose right mediaType:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
//here
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
imagePicker.delegate = self;