看到这样的代码,也不好意思说她们不是程序猿
唯一想到的是:
哦!原来北大青鸟是这么教的!
(1个弹出打开和保存文档,对话框的osx实现方法)
- (IBAction)OnBT_OpenSaveDialog:(id)sender
{
// File : no 扩展名
// NSSavePanel *savePanel = [NSSavePanel savePanel];
// [savePanel runModal];
NSSavePanel* panel = [NSSavePanel savePanel];
NSView *viewExt = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 180, 40)];
NSTextField *labExt = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 10, 80, 20)];
[labExt setBordered:NO];
[labExt setDrawsBackground:NO];
labExt.stringValue = @"File type: ";
NSComboBox *cbExt = [[NSComboBox alloc] initWithFrame:NSMakeRect(80, 8, 100, 25)];
//[cbExt addItemsWithObjectValues:@[@".bmp", @".jpg", @".png", @".tif"]];
[cbExt addItemsWithObjectValues:@[@".txt"]];
cbExt.stringValue = @".txt";
[viewExt addSubview:labExt];
[viewExt addSubview:cbExt];
[panel setAccessoryView:viewExt];
NSInteger result = [panel runModal];
if (result == NSFileHandlingPanelOKButton)
{
NSString *path = [[panel URL] path];
NSLog(path);
}
}
//ok!
- (IBAction)OnBT_OpenSelectedDialog:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setMessage:@""];
[panel setPrompt:@"OK"];
[panel setCanChooseDirectories:YES];
[panel setCanCreateDirectories:YES];
[panel setCanChooseFiles:YES];
NSString *path_all;
NSInteger result = [panel runModal];
if (result == NSFileHandlingPanelOKButton)
{
path_all = [[panel URL] path];
NSLog(path_all);
}
}
//test OK!
很9之前一个ios全栈程序猿和我说: mac的精髓在拖拉,和windows完全不同
不能更同意了
我觉得还有animate吧,感觉是挺优雅的,更人性
(他拥有iphone2~iphone5全系列,mac,pad, mac mini,反正就是出1个就买1个,真正用的人才更懂如何写程序)