简体   繁体   English

(iPhone,Obj-C)此“视图”属性从何而来?

[英](iPhone,Obj-C) Where does this “view” property come from?

I ran across this segment of code (in .m implementation file in an IBAction instance method): 我遇到了这段代码(在IBAction实例方法的.m实现文件中):

UIActionSheet *actionSheet = [[UIActionSheet alloc] ...];
...
[actionSheet showInView:self.view];

self refers to the button but I wanted to know where I could find out about this "view" property since I looked up UIButton, UIView, NSObject, but could not find out where this "view" property came from. self是指按钮,但是我想知道在哪里可以找到该“ view”属性,因为我查找了UIButton,UIView,NSObject,但找不到该“ view”属性的来源。

(also, any corrections on terminology would be appreciated since I am trying to learn all the correct terms - I'm a beginner iPhone programmer) (此外,由于我正在尝试学习所有正确的术语,因此请对术语进行任何更正-我是一名iPhone初学者)

The view property is one of a UIViewController. view属性是UIViewController之一。 The controller usually creates a view in its initialization, and is responsible for managing it. 控制器通常在初始化时创建一个视图,并负责对其进行管理。 Any subclass of UIViewController will inherit this property. UIViewController的任何子类都将继承此属性。 See this link for more details. 有关更多详细信息,请参见此链接 Also, you may want to familiarize yourself with MVC(model view controller), as this might make it more clear why the controller has a view property. 另外,您可能想熟悉MVC(模型视图控制器),因为这可以使控制器为何具有视图属性更加清楚。 See this link for more details. 有关更多详细信息,请参见此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM