When picking an image with a UIImagePickerViewController, a crop box like in the attached image shows up.
I don't want to force the user to pick a square image. I'd rather let the user pick their own aspect ratio, if easily possible, or if not, I want it to just use the original aspect ratio of the image.
I looked for anything relevant in the documentation for UIImagePickerViewController but found nothing.
Here's the code I'm using to configure and display the image picker:
(This gets called from elsewhere with either UIImagePickerControllerSourceTypeCamera or UIImagePickerControllerSourceTypePhotoLibrary, based on what button the user presses in my view controller.)
This probably isn't relevant but just incase, here's my implementation for the delegate callbacks:
Also probably an unnecessary detail, but just incase, these are methods of a subclass of a UITextView, not of a UIViewController. I realize this is violation of MVC, but this seemed like the best way to go since I wanted the pickers to come up based on touches in a UIMenuController. Thus the spots where I have self.viewController.
Those invoke this code:
But I think that's probably completely unrelated to my problem. My problem is probably in my configuration of the UIImagePickerController in the very beginning of my post.
I don't want to force the user to pick a square image. I'd rather let the user pick their own aspect ratio, if easily possible, or if not, I want it to just use the original aspect ratio of the image.
I looked for anything relevant in the documentation for UIImagePickerViewController but found nothing.
Here's the code I'm using to configure and display the image picker:
Code:
- (void)insertVisual:(UIImagePickerControllerSourceType)sourceType {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = sourceType;
imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
imagePicker.allowsEditing = YES;
imagePicker.delegate = self;
[self.viewController presentViewController:imagePicker animated:YES completion:NULL];
}
(This gets called from elsewhere with either UIImagePickerControllerSourceTypeCamera or UIImagePickerControllerSourceTypePhotoLibrary, based on what button the user presses in my view controller.)
This probably isn't relevant but just incase, here's my implementation for the delegate callbacks:
Code:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self.viewController dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSLog(@"Something was picked, now it needs to be inserted inline. This hasn't been implemented yet...");
[self.viewController dismissViewControllerAnimated:YES completion:NULL];
}
Also probably an unnecessary detail, but just incase, these are methods of a subclass of a UITextView, not of a UIViewController. I realize this is violation of MVC, but this seemed like the best way to go since I wanted the pickers to come up based on touches in a UIMenuController. Thus the spots where I have self.viewController.
Those invoke this code:
Code:
- (UIViewController *)viewController {
UIResponder *responder = self.nextResponder;
while (responder != nil && ![responder isKindOfClass:UIViewController.class]) {
responder = responder.nextResponder;
}
return (UIViewController *)responder;
}
But I think that's probably completely unrelated to my problem. My problem is probably in my configuration of the UIImagePickerController in the very beginning of my post.
Attachments
Last edited: