5
這就是我如何將一個打開的面板顯示爲一個浮動窗口。NSOpenPanel Sheet
有人可以幫我把面板作爲工作表運行嗎?窗口對象是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 2012-02-09 22:05:31
請解釋您收到的錯誤。 – 2012-02-09 22:48:21
對不起。我簡單地在*之後忽略了另一個} *;現在工作正常。謝謝您的幫助。 – user1198008 2012-02-09 23:03:26