5
これは、オープンパネルをフローティングウィンドウとして表示する方法です。NSOpenPanelシート
誰かがシートとしてパネルを使用して私を助けることができますか?ウィンドウオブジェクトはmWindowです。私が使用していた標準コードの多くは価値が下がっています。
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"mp3", @"mp2", @"m4a", nil];
[openPanel setAllowsMultipleSelection: NO];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanCreateDirectories:NO];
[openPanel setCanChooseFiles:YES];
[openPanel setAllowedFileTypes:fileTypes];
NSString * filePath = @"~/Desktop";
filePath = [filePath stringByExpandingTildeInPath];
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
[openPanel setDirectoryURL:fileURL];
NSInteger clicked = [openPanel runModal];
if (clicked == NSFileHandlingPanelOKButton) {
for (NSURL *url in [openPanel URLs]) {
NSString *urlString = [url path];
[input setStringValue:urlString];
NSString *myString = [input stringValue];
NSString *oldPath = [myString lastPathComponent];
[inputDisplay setStringValue:oldPath];
}
}
ありがとう - まだそれを得ることができません。解析エラーが発生しています。 – user1198008
どのようなエラーが発生しているのか説明してください。 –
申し訳ありません。私は単純に別の} * after *を省略していました。今はうまくいく。助けてくれてありがとう。 – user1198008