简体   繁体   English

UITableViewController中的View属性和TableView属性有什么区别?

[英]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. 由于UITableViewControllerUIViewController的子类,因此它将继承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. 对于UITableViewControllertableViewview属性是相同的。

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都相同但不同,你在UIViewControllerUITableView ,那么view属性将引用UIViewControllertableview将引用UITableView To avoid confusion always use tableview in case of UITableViewController 为了避免混淆,在UITableViewController情况下总是使用tableview

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

相关问题 .view UITableViewController和UICollectionViewController的属性 - .view Property of UITableViewController and UICollectionViewController UIViewController和UITableViewController有什么区别 - What is the difference between UIViewController and UITableViewController 定义方法的属性时,+和-有什么区别? - What is the difference between + and - when defining a property of method? Swift 中的属性和变量有什​​么区别? - What is the difference between a property and a variable in Swift? 使用方法和属性有什么区别? - What is the difference between using a method and a property? Restkit中的“属性”和“属性”有什么区别 - What's the difference between “attribute” and “property” in restkit 在UIPopoverController中呈现时,为什么UITableViewController self.tableView属性为Nil? - Why Is UITableViewController self.tableView Property Is Nil When Presented in UIPopoverController? 读写属性和非原子分配属性有什么区别? - what is the difference between a readwrite property and a nonatomic assign property? 属性观察者和属性包装器之间的主要区别是什么? - What's the main difference between property observers and property wrappers? UITableViewController 中 self.navigationController.view 和 self.view 的区别 - Difference between self.navigationController.view and self.view in UITableViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM