开发者

Subclassing UITableViewController what you get?

This is probably me being a little dim, I am setting up a UITableViewController via a UINavigationController, I have subclassed UITableViewController: (see below) and have implemented the datasource methods to get my table up and running

@interface RootViewController : UITableViewController {
    NSArray *dataList;
}
@property(nonatomic, retain) NSArray *dataList;
@end

My question is: when I came to implement the viewDidLoad for RootViewController I wanted to set the title for the table (See image below). I looked at the docs for UITableViewController and found that it had a property called "tableView" so I tried ...

[[self tableView] setTitle:@"Eeek!"];

This did not work, what I should have tried was ...

[s开发者_如何转开发elf setTitle:@"Eeek!"];

What I am wondering, when you subclass UITableViewController and add code your actually dealing with the tableView and not the UITableViewController, does this make sense?

Subclassing UITableViewController what you get?

Gary


what you are setting is actually the UIViewController (the parent class of UITableViewController) title, which is what UINavigationController uses to display a title in its navigationBar (the blue bar in your image)

Edit to better answer question: so no, when you subclass UITableViewController, you are actually dealing with the controller, not the table view itself.


Short answer to the question, no - you are still dealing with the properties of the Controller. The difference between the two setTitle: operations is:

// This message is being sent to the UITableViewController
[self setTitle:@"Eeek!"];

// This message is being sent to the UITableView property of the UITableViewController
[[self tableView] setTitle:@"Eeek!"];

There is no setTitle: method on the UITableView object, so that fails.

Abstractly in terms of MVC, the first is setting the property on a Controller and the second is setting the property on a View.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜