harshalb
harshalb

Reputation: 6054

How to load uitableview in one of the segment of segmented control?

i am developing an iphone application in which i want to apply table view on tapping on one of the segemnt of the segmented control .

i have done it as i am simply doing with uitableviewcontroller as parent class . But how can i do so with uiviewcontroller as parent class. is there any way to do

tableview.hidden = NO; other.hidden = YES;

in segmented control

or any other way to show a list.

Upvotes: 2

Views: 1842

Answers (1)

coneybeare
coneybeare

Reputation: 33101

Even as a UIViewController, you can add a table view and be a tableViewDelegate. You will have to programmatically create the tableView, setup the frame for it and add it to the viewController.subview.

Then, after you add the segment control, you can hide or show the tableview based on the state of the segment.

theTableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
theTableView.backgroundColor = [UIColor clearColor];
theTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
theTableView.delegate = self;
theTableView.dataSource = self;
[self.view addSubview:theTableView]

;

Upvotes: 2

Related Questions