IPhone SDK:How to use Segmented to Control two different TableView?

Right... well - you need to have a global BOOL eg BOOL isManual.

Up vote 0 down vote favorite share g+ share fb share tw.

Great thanks for reading and reply this question. Iphone uitableview uisegmentedcontrol link|improve this question edited Sep 27 '10 at 9:07 asked Sep 24 '10 at 8:49WebberLai433522 87% accept rate.

Right... well - you need to have a global BOOL eg BOOL isManual; now in each of your UITableViewDatasource methods you need to check this bool: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier autorelease; } if(isManual){ // set cell content for manual } else{ //set cell content for DCHP } return cell; } // this function allows you to set a table view cell as editable // look up UITableView delegate methods for more :) - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { if(isManual){ return YES; } else{ return NO; } } And similar. Then in your segmented control callback method you want to change isManual and reloadData on your table: - (void)segmentedControlChanged:(id)selector { UISegmentedControl *control = selector; int selected = control selectedSegmentIndex; if(selected == 0){ isManual == NO; } else{ isManual == YES; } self. TableView reloadData; } Hope that helps somewhat - although its rather vague.

:).

Thanks ,I think this logic is right,but I'm not yet to implement your code,I will try it ,and tell you is it work or not , only a little vague ,not big deal. – WebberLai Sep 24 '10 at 9:17 What if I use IB to create two tableview,than use if statement, if(selectedSegmentIndex == 0){view1. Hidden=NO;view2.

Hidden=YES;} else{view1. Hidden=YES;view2. Hidden=NO;},will it be more easier?

– WebberLai Sep 24 '10 at 9:31 I don't know... you could try it. :) I don't use IB if I'm doing complicated things like this you see. Its much more methodical to do it programatically.

:) – Thomas Clayson Sep 24 '10 at 9:32 I know ,I don't like IB too...I wish I can done every thing without IB...just using code! – WebberLai Sep 24 '10 at 9:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions