iOS - IBOutlet 的命名约定

Mar*_*elo 6 iboutlet ios swift

我确实进行了搜索,发现了很多约定,但没有一个谈论 IBOutlet。

我应该使用以下哪一项?

@IBOutlet weak var price: UITextField!
@IBOutlet weak var priceTextField: UITextField!
@IBOutlet weak var textFieldPrice: UITextField!
@IBOutlet weak var tfPrice: UITextField!
Run Code Online (Sandbox Code Playgroud)

小智 6

这是我在开发人员代码中最常看到的 IBOutlet 命名约定。

@IBOutlet weak var priceTextField: UITextField!
Run Code Online (Sandbox Code Playgroud)

  • 如果你有 5 个 UITextFields 并且你忘记了如何命名第 4 个文本字段,那么将这些文本字段命名为 textFieldUsername 不是很容易吗?现在,如果你忘记了名称,你可以随时从 textField 开始并等待 Xcode 自动完成。 (7认同)