[英]What is the difference between the View property and TableView property in UITableViewController?
After doing some research in apple documentation here's what I found. 在对苹果文档进行一些研究后,我发现了这些。
In UIViewController , the view property 在UIViewController中 , view属性
@property(nonatomic, retain) UIView *view
means the view that the controller manages. 表示控制器管理的视图。
and 和
In UITableViewController , the tableView property 在UITableViewController中 , tableView属性
@property(nonatomic, retain) UITableView *tableView
means the tableView that the controller manages. 表示控制器管理的tableView。
Since UITableViewController is the subclass of UIViewController , it will inherit the view property. 由于UITableViewController是UIViewController的子类,因此它将继承view属性。 So when I'm writing codes in UITableViewController subclass file, there's these 2 properties that always confuses me and I'm not sure when to use it.
因此,当我在UITableViewController子类文件中编写代码时,这两个属性总是让我困惑,我不知道何时使用它。 Please explain.
请解释。 Thanks.
谢谢。
For a UITableViewController
, the tableView
and view
properties are the same. 对于
UITableViewController
, tableView
和view
属性是相同的。
Use the tableView
property in your table view controller when you need to access the table view and make use of various UITableView
properties and methods. 当您需要访问表视图并使用各种
UITableView
属性和方法时,请在表视图控制器中使用tableView
属性。 Or even if you need plain old UIView
methods. 或者即使你需要普通的旧
UIView
方法。
It's fine to use the view
property in cases where you only need UIView
properties and methods. 在只需要
UIView
属性和方法的情况下使用view
属性是很好的。 It's really a matter of taste which property to use in this case. 在这种情况下使用哪种属性真的是一个品味问题。
In case of UItableViewController
both are same but different in you have UITableView
in the UIViewController
then view
property will refer to UIViewController
and tableview
will refer to UITableView
. 如果
UItableViewController
都相同但不同,你在UIViewController
有UITableView
,那么view
属性将引用UIViewController
, tableview
将引用UITableView
。 To avoid confusion always use tableview
in case of UITableViewController
为了避免混淆,在
UITableViewController
情况下总是使用tableview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.