I am using UIImagepickerController to capture video in my app.
Sometimes it behaves strangely - that image capturing is coming. Mostly it comes when a new user is registered and try to capture a video or a new ipa file is installed and tested. Eventhough it appears randomly.
When I prompt UIImagepickerController it display take photo button (White button) instead of video record button (Red button)
Here is my code -
UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
imagePicker.delegate=self;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
}
[self presentViewController:imagePicker animated:YES completion:NULL];
Just try replacing your code with this.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
// picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMoviekUTTypeImage];
picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,nil];
//picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
Related
Thumbnails do not display in the UIImagePickerController when running on iPhone 11 or real device with iOS 14.
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentViewController:picker animated:YES completion:nil];
Result:
Photos and Albums showing as Blank but when I tap on-screen image will be selected.
For me, it was caused by using
UIScrollView.appearance(whenContainedInInstancesOf: [UINavigationController.self]).backgroundColor = .backgroundPrimaryNew
I don't know why is that, but after I've removed this line it began working again and thumbnails are showing.
Try this
Instead of presenting add UIImagePickerController as subView
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self.view addSubview:self.picker.view];
[self addChildViewController:self.picker];
[self.picker didMoveToParentViewController:self];
This is my code to present the UIImagePickerController:
UIImagePickerController *imagepicker = [[UIImagePickerController alloc] init];
imagepicker.delegate = self;
imagepicker.view.backgroundColor = [UIColor orangeColor];
UIImagePickerControllerSourceType sourcheType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.sourceType = sourcheType;
imagepicker.allowsEditing = YES;
[self presentViewController:imagepicker animated:YES completion:nil];
This is the image where the error occurred
This is a normal picture
This happens on one iPad (iOS 11.1.2), but it works fine on the other (iOS 8.4.1). I tried the changes, but none seemed to work.
I am currently working on an a video app in which I'd like to give the user the option of setting the duration for which the video will be recorded. I am trying to implement this using a stepper button. Currently I am able to set this timer statically as follows:
- (IBAction)captureVideo:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
picker.videoMaximumDuration = 10.0f;
[self presentViewController:picker animated:YES completion:NULL];
}
}
How can I use a stepper's value instead? Or are there any better ways of doing this?
Thanks.
You can see this example, You'll know how to use UIStepper.
Following along with this tutorial, I'm trying to make a very simple iOS video app to learn the api. The tutorial tell us to put a button on the view that, when pressed, uses the UIImagePickerController api (a modal or popup view) to show the camera controls. For my app, I wanted the UIImagePickerController (or rather the camera functionality) to appear, not when the button was pressed, but rather when the app opened. When I moved the code into viewDidLoad, I got this error message
2014-06-27 17:04:48.754 VideoBlah[33679:60b] Warning: Attempt to present <UIImagePickerController: 0x1658d4d0> on <ViewController: 0x165be6f0> whose view is not in the window hierarchy!
I therefore tried to get self.view to presentViewController like this
[self.view presentViewController:picker animated:YES completion:NULL];
but UIView doesn't have the selector presentViewController.
Is there a way to get the popup view controller for the UIImagePickerController to appear when the app opens rather than waiting for the user to present a button?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//
// UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// picker.delegate = self;
// picker.allowsEditing = YES;
// picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
//
// [self presentViewController:picker animated:YES completion:NULL];
// }
}
- (IBAction)captureVideo:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
[self presentViewController:picker animated:YES completion:NULL];
}
}
Try using this code in viewDidAppear.
I want to crop a photo that is taken in the app and then save. I am using the GKImagePicker so that I can do this but if I use the code below even though I push the take photo button in my app it shows me the photo library which I pick to crop. I do not want to do this and just want to crop my photo which I have taken in the app.
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 320);
self.imagePicker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
[self presentViewController:picker animated:YES completion:NULL];
}
Remove the last line in your code:
[self presentViewController:picker animated:YES completion:NULL];// remove
and give it a try ;)
You can also check this.