首页 > 代码库 > 打开openPanel的代码

打开openPanel的代码

- (IBAction)openPDFFile:(id)sender {

    NSOpenPanel *panel = [NSOpenPanel openPanel];

    [panel setAllowsMultipleSelection:YES];

    NSArray* fileArray = [NSArray arrayWithObjects:@"pdf", nil];

    [panel setAllowedFileTypes:fileArray];

    

    [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {

        if (result == NSOKButton)

        {

            [panel close];

            NSWindow *keyWindow = [NSApplication sharedApplication].keyWindow;

            if (self.window == keyWindow) {

                [[self homeViewCtrl].collectionView addItemsWithURLs:[panel URLs]];

            }

        }

    }];    

}

 

打开openPanel的代码