0

A very newbie in XCOde.. Currently Im using 4.2. Im making a walk through of an app that do specific function. Im just doing step by step process how the app should work/flow.

I just want to know how to hide/unhide specific table cell/row once a button or segmented control is clicked. Hope you could give a sample.

These are my sample table cells/rows

if (indexPath.row == 0){cell.textLabel.text = @"angel";}
if (indexPath.row == 1){cell.textLabel.text = @"bird";}
if (indexPath.row == 2){cell.textLabel.text = @"dog";}
if (indexPath.row == 3){cell.textLabel.text = @"elephant";}
if (indexPath.row == 4){cell.textLabel.text = @"flower";}

I just want row2 or any row to be hidden once a button or segmented control is clicked. Vise versa, unhide the row/cell again once a button/segmented control is clicked button is clicked.

Many thanks for immediate responce!!

warrenm
  • 31,094
  • 6
  • 92
  • 116
ray
  • 95
  • 3
  • 4
  • 11

1 Answers1

0

Tables don't store data, they are merely a representation of managed data somewhere.

What you can do is create an array (or multiple depending on how many sections you have in your table) and have the table reflect the contents of the array. If it's row two that you want hidden, you can remove objectAtIndex:two from the array.

After any changes to the array you can call the method [myTable reloadData] and it will cycle through the delegate methods again and reflect the changes.

esreli
  • 4,993
  • 2
  • 26
  • 40
  • Hi! Actually I think I have found something I need [here](http://stackoverflow.com/a/8309563/1474353) But I dont know how to call the specific table cell/row and where to place the code. Im using segmented control and buttons to hide and unhide the cell. Thanks! – ray Jul 06 '12 at 04:48
  • Can you post some code? I am happy to give advice if I can see what it is you are talking about. – esreli Jul 06 '12 at 05:03
  • Hi @Eli Gregory, Seems like I cant post long comment. BAsically I want my segmented control - (IBAction)ContSegCont:(id)sender { switch (self.ContSegCont.selectedSegmentIndex) { case 0: //After Clicking This segment the table will hide/unhide Someting like this [cell setHidden:YES]; case 1: //After Clicking This segment the table will hide/unhide Someting like this [cell setHidden:YES]; case 2: //After Clicking This segment the table will hide/unhide Someting like this [cell setHidden:YES]; break; – ray Jul 06 '12 at 05:47