gpt4 book ai didi

cocoa - 如何在 cocoa 应用程序中实现NSForm?

转载 作者:行者123 更新时间:2023-12-03 16:29:56 26 4
gpt4 key购买 nike

我想在我的应用程序中实现 NSForm View ,我是 cocoas 应用程序的新手。您能给我有关此 Controller 的建议吗?提前致谢。

最佳答案

您可以通过多种方式在应用程序中使用 NSForm。

  1. 在 nib 文件中添加 NSForm
  2. 通过编程创建 NSForm 并将该 NSForm 附加到您的窗口 View 中。

@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

我认为这应该可以帮助您入门。

如果您有任何疑问,请告诉我。

关于cocoa - 如何在 cocoa 应用程序中实现NSForm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2880764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com