tags:

views:

73

answers:

2

Hi I am very very new to the iPhone programming. I am kind of playing with the sample code. My first question is if it is possible to add the UITableView with the code only. If it is then here is my code that i am trying to add UITableView to the navigation controller.

analyticsTable = [[UITableView alloc] init];    
[self.view.window addSubview:analyticsTable];
[self.view removeFromSuperview];

I dont know how to go about it

Thanks Varun

A: 

You need to set a frame, delegate and datasource. See this for more info

http://www.iphonedevsdk.com/forum/iphone-sdk-development/52938-uitableview-programmatically-creating-adding-datasource-delegate.html

Read to the bottom.

Lou Franco
+1  A: 

Take a look at the docs provided by Apple at http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/TableView_iPhone/CreateConfigureTableView/CreateConfigureTableView.html

Check about halfway down the bottom in the section "Creating a Table View Programmatically". I think that's exactly what you want.

These taught me how to programmatically do tables. I've never needed to use IB.

John Smith
[Direct Link](http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/TableView_iPhone/CreateConfigureTableView/CreateConfigureTableView.html#//apple_ref/doc/uid/TP40007451-CH6-SW4) to sample. Make a view controller for the table view, then push the view controller onto your navigation controller.
drawnonward
thanks drawnonward
John Smith
Thanks John, I tried the solution on Apple's website and it worked perfectly.
varun
So do I get a checkmark?
John Smith
I am sorry i am still new to the forum. Didnt know that once you get the solution right you need to checkmark.DoneThanks again for the help.
varun