有沒有辦法強制NSOpenPanel關閉,以便在調試時看到屏幕?在調試過程中,我無法在Xcode中看到代碼,我也無法移動面板。NSOpenPanel在調試期間保持打開狀態
這是我有:
- (IBAction)openImage:(id)sender {
NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"jpg", @"JPG", nil];
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:NO];
[panel setAllowedFileTypes:fileTypes];
[panel beginWithCompletionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
self.image = [[NSImage alloc] initWithContentsOfURL:panel.URL];
[panel close];
[self doSomethingWithImage];
}else{
}
}];
}
- (void) doSomethingWithImage {
// if I put a breakpoint here,
// the NSOpenPanel is still on the screen and I can't move it.
}
我試過這個,它不適合我。 – Alex311