views:

483

answers:

2

Hey guys,

I need some help.

I've got a segmented control. if segment 0 is clicked it shows a UIView, containing a uitableview. If segment 2 is clicked it shows another UIView which contains a uitableview as well.

These two tableviews got the same datasource. But i want the second tableview to have an other datasource. SO i thougth of loading another nib into the second uiview containing a the tableview which gets its data from the corresponding .m file.

I don't know wheather this is the best solution. If you've got any other ideas let me know :)

thanks in advance!

A: 

Do you know that you can have the same tableview display different data sets? You don' have to use an entirely different NIB just to change UITableViews so you can display different data. Or am I understanding your question incorrectly?

mahboudz
A: 

I think the best way to do this is to have just one table view. In the cellForRow method have a conditional which queries the state of the segmented control. Depending on the result of that if statement, return the type of cell you want. In addition, in your segmented control callback you'll have to do a [tableView reloadData]

bpapa
thanks good idea :)
jacky