gpt4 book ai didi

cocoa - 在 Interface Builder 中设置操作时控制拖动操作方向的重要性

转载 作者:行者123 更新时间:2023-12-03 17:07:36 24 4
gpt4 key购买 nike

我有一个关于在使用 Interface Builder (3.2.3) 设置操作时选择控制拖动操作的正确起点和终点的重要性的问题。这个问题是在处理介绍性文本中的示例时出现的。在示例项目中,有一个非常简单的图形窗口,其中包含三个 NSTextField(即名字、姓氏、电子邮件)和一个 NSTextView。 Controller 类的接口(interface)在头文件中声明为:

@interface EmailController : NSObject {

IBOutlet NSTextField *emailField;
IBOutlet NSTextField *firstNameField;
IBOutlet NSTextField *lastNameField;
IBOutlet NSTextView *resultTextView;

}

- (IBAction)textFieldChanged:(id)sender;

@end

文本指出,在设置操作时,您可以在控件上按住 Ctrl 键并拖动。具体来说,该示例首先从 First Name 可编辑 NSTextField 文本字段按住 Control 键拖动到 EmailController 实例,其中会出现一个黑色小窗口,并且可以选择操作 textFieldChanged 操作。

将名字可编辑框连接到操作后,文本会引导读者将姓氏和电子邮件可编辑框也连接到同一操作。然而,在这些情况下,文本会引导读者开始从小圆圈到 Controller 实例黑色窗口中 textFieldChanged 操作右侧的 Control 拖动操作,并在“姓氏”和“电子邮件”可编辑框处结束。这似乎与我理解的从控件开始设置操作的一般规则相反。

无论我选择哪一点作为起点和终点,我似乎都会得到相同的结果。连接器检查器中列出的各种对象的操作似乎总是与我选择的起点无关。如果不是它看起来与明确规定的一般规则相矛盾,我什至不会认为这是一个问题。当我尝试对 socket 做同样的事情时,我确实注意到了一个问题。

将控件连接到操作时选择哪个点作为起点重要吗?

谢谢

最佳答案

Does it matter which point you choose as the start when connecting a control to an action?

没有。

Big Nerd Ranch recommends always dragging from sender to receiver (导出到对象或控制到目标)以明确消息将进入哪个方向。向另一个方向拖动同样有效,但不会向新的 Cocoa 和 Cocoa Touch 程序员强化消息方向。

(需要明确的是,该博客是由前 BNR 类(class)参与者撰写的,而不是由 BNR 或为 BNR 工作的任何人撰写的。)

After the First Name editable box is connected to the action the text directs the reader to also connect the Last Name and Email editable boxes to the same action. However in these cases the text directs the reader to start the control-drag operation from the small circle to the right side of the textFieldChanged action in the black window of the controller instance and to end at the Last Name and Email editable boxes. This seems opposite to how I understand the general rule of starting at the control while setting an action.

右键单击操作接收器并从操作中拖动的方式的一个优点是更容易一次连接一堆操作。这听起来像是教程破例的最好理由,除了由不同的作者或不同的作者(我猜)采用不同的做事方式之外。

关于cocoa - 在 Interface Builder 中设置操作时控制拖动操作方向的重要性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3747202/

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