Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iPad support #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions CRMediaPickerController/CRMediaPickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ - (void)presentMediaPickerWithSourceType:(CRMediaPickerControllerSourceType)sour
UIImagePickerControllerSourceType imagePickerSourceType = [self imagePickerControllerSourceTypeFromMediaSourceType:sourceType];

if (![UIImagePickerController isSourceTypeAvailable:imagePickerSourceType]) {

NSString *photoLibraryNotAvailableMessage = NSLocalizedString(@"Photo Library not available", nil);

if (imagePickerSourceType == UIImagePickerControllerSourceTypeCamera) {
NSString *photoLibraryNotAvailableMessage = NSLocalizedString(@"Photo Library not available", nil);
if (imagePickerSourceType == UIImagePickerControllerSourceTypeCamera) {

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Camera not available", nil)
message:nil
Expand Down Expand Up @@ -133,7 +131,7 @@ - (void)presentMediaPickerWithSourceType:(CRMediaPickerControllerSourceType)sour

}
return;
}
}

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
Expand Down Expand Up @@ -202,17 +200,23 @@ - (void)presentMediaPickerWithSourceType:(CRMediaPickerControllerSourceType)sour
if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)) {//&& (sourceType == UIImagePickerControllerSourceTypePhotoLibrary)) {
self.popoverController = [self makePopoverController:self.imagePickerController];
self.popoverController.delegate = self;

[self.popoverController presentPopoverFromRect:CGRectMake(400, 400, 100, 100) inView:self.delegate.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:self.imagePickerController];
if ([self.imagePickerController respondsToSelector:@selector(popoverPresentationController)] ) { // iOS8
self.imagePickerController.popoverPresentationController.sourceView = self.delegate.view;
}

dispatch_async(dispatch_get_main_queue(), ^ {
[self.popoverController presentPopoverFromRect:CGRectMake(400, 400, 100, 100) inView:self.delegate.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
});

/*
if (self.showFromBarButtonItem) {
[self.popoverController presentPopoverFromBarButtonItem:self.showFromBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self.popoverController presentPopoverFromRect:self.showFromRect inView:self.showFromViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
*/

} else {
[self.delegate presentViewController:self.imagePickerController animated:YES completion:nil];
}
Expand Down Expand Up @@ -263,7 +267,7 @@ - (CRMediaPickerControllerSourceType)imagePickerControllerSourceTypeFromSourceTy

- (void)chooseMedia
{
NSString *cancelButton = NSLocalizedString(@"Cancel", nil);
NSString *cancelButton = NSLocalizedString(@"Cancel", nil);

NSString *mediaTypeString = @"photo or video";
if ((self.mediaType & CRMediaPickerControllerMediaTypeImage) && !(self.mediaType & CRMediaPickerControllerMediaTypeVideo)) {
Expand All @@ -275,10 +279,7 @@ - (void)chooseMedia
NSString *lastTakenLocalizedString = [NSString stringWithFormat:@"Last %@ taken", mediaTypeString];

NSString *lastTakenButton = NSLocalizedString(lastTakenLocalizedString, nil);

NSString *photoLibraryButton = NSLocalizedString(@"Photo Library", nil);
NSString *savedPhotosButton = NSLocalizedString(@"Saved Photos", nil);
NSString *cameraButton = NSLocalizedString(@"Camera", nil);
NSString *photoLibraryButton = NSLocalizedString(@"Photo Library", nil); NSString *savedPhotosButton = NSLocalizedString(@"Saved Photos", nil); NSString *cameraButton = NSLocalizedString(@"Camera", nil);

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
Expand Down Expand Up @@ -395,8 +396,7 @@ - (void)getLastMediaTaken
#pragma mark - UIActionSheetDelegate

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
{ UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];

Expand Down