我想在我的应用程序中实现NSForm视图我是cocoas应用程序的新手。你能告诉我这个控制器吗?在此先感谢。
答案 0 :(得分:4)
您可以通过不同的方式在应用程序中使用NSForm。
@ 2我有一个你可以理解的例子
NSWindow*window = [self window]; // gets current widnow
NSView *theContentView = [window contentView]; // gets view from window
NSRect contentRect = [theContentView frame]; // gets frame from view
NSRect formRect = NSMakeRect( 0, 50, 300, 220 ); // creates new frame
NSForm *theForm;
theForm = [[NSForm alloc] initWithFrame:formRect]; // init with frame fromRect
NSFormCell *theFormCell; // create cell for form
// defines first cell with field First Name
theFormCell = [theForm addEntry:@"First Name:"];
[theFormCell setTag:EContactFieldTag_FirstName];
// defines first cell with field Last Name
theFormCell = [theForm addEntry:@"Last Name:"];
[theFormCell setTag:EContactFieldTag_LastName];
[theForm setCellSize:NSMakeSize( 300, 25 )]; // defines size for cell
[theForm sizeToCells];
[theForm setKeyCell:theFormCell]; // assign cell to form
[theContentView addSubview:theForm]; // add form to current view
我认为这应该可以帮助你开始。
如果您有任何问题,请与我们联系。