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