PHPickerViewController displays the photo picker with shrunken UI

I need to create a Mac application using Objective-C. The application has to use PHPickerViewController to provide user a familiar interface to pick photos. Here is the Objective-C code that used to present the photo picker.

//ViewController.h
#import <Cocoa/Cocoa.h>
#import <PhotosUI/PhotosUI.h>

@interface ViewController : NSViewController<PHPickerViewControllerDelegate>

@property (nonatomic, weak) IBOutlet NSImageView *myImageView;

@end

// ViewController.m
@implementation ViewController
PHPickerViewController* pickerViewController = nil;
- (void)pickPhotos {
    PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];
    config.selectionLimit = 0; // Allow multiple selections
    config.filter = [PHPickerFilter imagesFilter]; // Filter for images

    pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];
    pickerViewController.preferredContentSize = NSMakeSize(800, 600);
    pickerViewController.delegate = self; // Set the delegate to handle selection
    [self presentViewControllerAsModalWindow:pickerViewController];
- (IBAction)clicked:(id)sender {
    NSLog(@"Button Clicked");
    [self pickPhotos];
}
- (void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray<PHPickerResult *> *)results {

    if (pickerViewController) {
        [picker dismissViewController:pickerViewController];
    }
}
@end

Can you please guide me to show the photo picker to a bigger size?

Answered by DTS Engineer in 868917022

Hey @brightdl,

Thanks for submitting that Feedback!

Just adding in here that you should also be able to set the PHPickerViewController's view's frame, for example:

    pickerViewController.view.frame = NSRect(origin: .zero, size: .init(width: 800, height: 600))

Technically, this is only documented as being supported when the picker controller is added as a child of another view controller, but in practice I think it should work here without doing the view controller containment dance. (If you'd like to be safe though, you can definitely do this with some simple view controller containment.)

--Greg

pickerViewController.preferredContentSize = NSMakeSize(800, 600); This doesn't work.

Thanks for providing some code. I was able to reproduce the problem you have described here.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

Thank you for suggesting to submit a feedback. I have submitted a feedback and the number is FB21305603.

Hey @brightdl,

Thanks for submitting that Feedback!

Just adding in here that you should also be able to set the PHPickerViewController's view's frame, for example:

    pickerViewController.view.frame = NSRect(origin: .zero, size: .init(width: 800, height: 600))

Technically, this is only documented as being supported when the picker controller is added as a child of another view controller, but in practice I think it should work here without doing the view controller containment dance. (If you'd like to be safe though, you can definitely do this with some simple view controller containment.)

--Greg

PHPickerViewController displays the photo picker with shrunken UI
 
 
Q