views:

848

answers:

1

Hello iphone devs,

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.

+1  A: 

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]

;

coneybeare
where shold i load it in the viewdidload or segmentcontrol's value changed (custom method ) ?
hib
viewDidLoad is a fine place to do it
coneybeare
can you show me how to initialize the frame and set delagate . sorry for asking more . but i am not getting the solution by googling . and new to iphone
hib
maintain a theTableView Pointer in your .h file.<br /> 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];
coneybeare
i will add it as part of the answer
coneybeare
thanks man i've done it yuppy
hib