PDA

View Full Version : Confused by View




freeme007
Feb 9, 2012, 02:14 PM
I created a view controller class called ItemsViewController and it's a subclass of UITableViewController. From What I understand is that the UITableViewController is a subclass of UIViewController and UITableViewController inherits the View method from UIViewController. The UITableViewController has a UITableView. So when I do the following:
self.window.rootViewController = itemsViewController
it loads an empty table view instead of a white screen, Why?



ArtOfWarfare
Feb 9, 2012, 02:46 PM
That isn't the actual code, you're missing a semicolon.

Share your actual code and we can explain it to you.

phantax
Feb 9, 2012, 02:47 PM
Perhaps I am confused, but it seems like you answered your own question already.

Your itemsViewController is a subclass of UITableViewController, but you are confused as to why it contains a TableView?

A UITableViewController will load the TableView that is present in the associated xib. If no xib is present, it will provide you with a basic unconfigured TableView.

Have you read the UITableViewController Class Reference? I am sure it explains this behavior pretty clearly.

freeme007
Feb 9, 2012, 02:56 PM
Perhaps I am confused, but it seems like you answered your own question already.

Your itemsViewController is a subclass of UITableViewController, but you are confused as to why it contains a TableView?

A UITableViewController will load the TableView that is present in the associated xib. If no xib is present, it will provide you with a basic unconfigured TableView.

Have you read the UITableViewController Class Reference? I am sure it explains this behavior pretty clearly.

What happened to the view that's been inherited from UIViewController which is an UIView ? So I guess the default view for UITableViewController is the UITableView, not the inherited UIView?

chrono1081
Feb 9, 2012, 03:04 PM
What happened to the view that's been inherited from UIViewController which is an UIView ? So I guess the default view for UITableViewController is the UITableView, not the inherited UIView?

I think we are all pretty confused what you are asking...

If you have a UITableViewController then it would be safe to assume the UITableView is the default view (which is how you should set it) since the controller is the "messenger" so to speak between your instance of UITableView and your data.

jonnymo5
Feb 9, 2012, 03:22 PM
I created a view controller class called ItemsViewController and it's a subclass of UITableViewController. From What I understand is that the UITableViewController is a subclass of UIViewController and UITableViewController inherits the View method from UIViewController. The UITableViewController has a UITableView. So when I do the following:
self.window.rootViewController = itemsViewController
it loads an empty table view instead of a white screen, Why?

Because, as you said, it is a subclass of UITableViewController. If you want a blank white screen then make a subclass of UIViewController.

MattInOz
Feb 10, 2012, 04:23 AM
What happened to the view that's been inherited from UIViewController which is an UIView ? So I guess the default view for UITableViewController is the UITableView, not the inherited UIView?

As far as I know nothing. It's exactly where you left it.

As I Understand...
UITableViewController added a UITableView as a subview of the UIView it inherited when it subclassed UIViewController. When you add yourViewController to the viewContainer you are using the viewContainer looks for the that UIView from the origin UIViewController to add as a sub-view of it's view chain.