I tried this twice with two different apps and I get the same thing. I have a set up a UIImagePIckerController instance as follows:
- (IBAction)addImage:(UIBarButtonItem *)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
if ([mediaTypes containsObject:(NSString *)kUTTypeImage]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
picker.allowsEditing = NO;
picker.showsCameraControls = NO;
[self presentViewController: picker animated:YES completion:NULL];
}
[..]
}
This was the second. In the first I set up a custom overlay to run the shutter and other functions. Everything runs fine but I keep getting an error on the console:
<Error>: CGAffineTransformInvert: singular matrix.
When I run the app, every time I rotate (or move about which signals a rotate) the device while the camera is up {something happens here}. I tried it on both my iPhone 4 and iPad Mini with the same results. After a lot of digging I found this only happen in the case where
picker.showsCameraControls = NO;
If I put
picker.showsCameraControls = YES;
Then I get no message (though my custom overlay is hidden too). Making sure it wasn't the custom overlay itself I tried leaving that out, and it still gives the error message.
Anybody got any ideas of what I should do about this?
I believe it to be largely benign as Apple's own PhotoPicker sample code generates this warning. Rotation has to do with matrices and while I'm not sure which matrix in particular is getting rotated, it is considered a mathematical violation to perform operations on matrices with a determinant of zero (similar to dividing by zero). Such a matrix is not invertible or 'singular':
http://en.wikipedia.org/wiki/Rotation_matrix
http://en.wikipedia.org/wiki/Determinant
http://en.wikipedia.org/wiki/Singular_matrix#singular
Related
After testing my app on an iPhone 6S+, I noticed the videos it produced were only 1080p, despite the fact that it should be capable of recording in 4K. My UIImagePickerController is set up like so:
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.mediaTypes = #[(NSString *)kUTTypeMovie];
imagePickerController.videoMaximumDuration = 3600.f;
imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
[self presentViewController:imagePickerController animated:YES completion:nil];
I thought that perhaps there would be a new UIImagePickerControllerQualityType key for selecting 'very high' quality, but 'high' still seems to be the best quality available. Is there a way to enable 4K recording using UIImagePickerController, or do I have to roll my own solution using AVFoundation?
In some iOS version this was solved and now, doing
picker.videoQuality = .typeHigh
my iPhone is taking 4k videos.
I've been unable to get the trim controls to appear when capturing an iOS movie.
Here's my code:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = #[(__bridge NSString *)kUTTypeMovie, (__bridge NSString *)kUTTypeImage];
imagePicker.allowsEditing = YES;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];
Additionally, I'm capturing the reply with imagePickerController:didFinishPickingMediaWithInfo:.
From searching StackOverflow I'm aware that I need to actually trim the video myself. That doesn't seem too difficult, but while I get the image picker and can capture a video I can't get the trim controls to appear! What am I missing?
My mistake was just in using video samples that were too short. They need to be over a certain length before the trimming tools will appear.
When I try use "ABPeoplePickerNavigationController" or "UIImagePickerController", in most cases it won't load up correctly. It will show part of the screen (transparent) starting in the middle of the screen in iOS 7 (ipad) for both simulator and device (screenshot below). In iOS 8 everything works correctly.
This is the code I use for ABPeoplePickerNavigationController:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
self.preserveCurrentEntity = YES;
[self presentViewController:picker animated:NO completion:nil];
UIImagePickerController will break just for picking videos, but work for everything else, this is the code I use:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
switch (buttonIndex) {
case ImagePickerModeCamera:
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
break;
case ImagePickerModeAlbum:
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
break;
default:
break;
}
imagePicker.delegate = self;
NSMutableArray *mediaType = [[NSMutableArray alloc] init];
switch (self.actionSheetType) {
case ActionSheetTypeImage:
[mediaType addObject:(NSString*)kUTTypeImage];
break;
case ActionSheetTypeVideo: {
[mediaType addObject:(NSString*)kUTTypeMovie];
[mediaType addObject:(NSString*)kUTTypeVideo];
imagePicker.allowsEditing =NO;
}
break;
default:
break;
}
imagePicker.mediaTypes = mediaType;
[self presentViewController:imagePicker animated:NO completion:nil];
This is what happens in iOS7 when loading ABPeoplePickerNavigationController:
This is what happens in iOS8 when loading ABPeoplePickerNavigationController:
What is the solution to fix this?
Looks like I found the solution to my problem.
I have a root view controller that has two xibs, one for iPad and one for iPhone. It seems my iPad one was causing the trouble even though they were very similar (just one was larger). I couldn't figure out why.
I just use the iPhone one now and make sure it resizes correctly on iPad and everything is working correctly.
I have the same problem like you, but after wasting some time I got some post, that what may be the reason in your case.
iPhone Library does not work on the iOS Simulator in special case of picking Vedio
Referred Post for my solution. and worked for me.
Update on it, if you still facing problem, I can post my code to help you.
HTH, Enjoy Coding !!
When i try to load camera from my code, camera preview is black. If I wait for 10-20 seconds it will show real camera preview. I found several questions and some of them suggest that running some other code in background should be the reason for this. However I don't have any code running in background.
How should I fix this?
This is my code where I run camera
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:photoPicker animated:YES completion:NULL];
About 5 months ago my team discovered a memory leak with UIImageViewController in iOS7. Each instantiation slowed down the app exponentially (i.e. first alloc-init had a 1 second delay, second had a 2 second delay, third had a 5 second delay). Eventually, we were having 30-60 delays (similar to what you're experiencing).
We resolved the issue by subclassing UIImagePickerController and making it a Singleton. That way it was only ever initialized once. Now our delay is minimal and we avoid the leak. If subclassing isn't an option, try a class property in your viewController and just lazy load it like so.
-(UIImagePickerController *)imagePicker{
if(!_imagePicker){
_imagePicker = [[UIImagePickerController alloc]init];
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
return _imagePicker;
}
Then you can just call it later like:
[self presentViewController:self.imagePicker animated:YES completion:nil];
Had this myself - it happens if something is running on the main dispatch thread - are you resizing images by any chance?
It puts the preview onto the main thread and if something is using it, you get a black screen. It's a bug and the workaround is to either take over the main thread or to disable the photo picker until the queue is free
This Should work for you:
- (void)cameraViewPickerController:(UIImagePickerController *)picker
{
[self startCameraControllerFromViewController: picker
usingDelegate: self];
}
- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose movie capture
cameraUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, (NSString *) kUTTypeMovie,nil];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = NO;
cameraUI.delegate = delegate;
[controller presentViewController:cameraUI animated:YES completion:nil];
return YES;
}
I am trying to implement a feature of taking X amount of pictures programmatically after entering a UIViewController for both the iPhone and iPad. I looked into UIImagePickerController but I do not want to present the camera controls and have the user hit a button to capture only one photo. Is there a way to capture X amount of photos once entering a UIViewController and storing all the photos in the end for future reference in one go?
Edit:
-(void)viewDidAppear:(BOOL)animated
{
// Create image picker controller
picker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
// Set source to the camera
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Delegate is self
picker.delegate = self;
// Allow editing of image ?
picker.allowsEditing = NO;
//picker.showsCameraControls = NO;
// Show image picker
[picker animated:YES completion:nil];
}
straight away with takePicture you can not take multiple snaps, for that you have to use some video recording and get snap out of it for particular frame or time, for you more reference you can use this apple documentation for bulk snaps AVFoundation Programming Guide
You can try something like this:
int numberOfPhotos = 3; // Number of photos you want to take.
for ( int i = 0; i < numberOhPhotos; i++ )
{
// Note that you should use some sort of a pause in between each photo.
[picker takePicture];
}