I can't get it to show any alert if I try to use a not allowed extension. When I say "not allowed" I mean I wrote

setAllowsOtherFileTypes:FALSE

but it doesn't work. If I set the allowed file types to an array of @"jpg" and @"png" (for example), and then I try to save "file.tif", I get no alert and the resulting filename is "file.tif.jpg" What's happening? I'm on MacOS 10.6.8, Xcode 3.2.6

Thank you very much

有帮助吗?

解决方案

NSSavePanel* savepanel = [NSSavePanel savePanel];
 // set the save panel to only do jpg and png file
    [savepanel setAllowedFileTypes:[NSArray initWithObjects:@"jpg", @"png",nil]];
    [savepanel setAllowsOtherFileTypes:YES];
 // run the panel
if ([savepanel runModal] != NSFileHandlingPanelOKButton)
  return NO;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top