0

ill try to hide a row in Swift. If i select in the function heightForRowAtIndexPath to return for the specific row height 0, then there is a problem with my content (i will be overlapped) - if i select the row everythink looks as expected.

Is this maybe a bug in swift? Or what is the correct way to hide a row in Swift (Objective C).

Thanks in Advance

derdida
  • 14,784
  • 16
  • 90
  • 139
  • http://stackoverflow.com/questions/1633966/can-i-force-a-uitableview-to-hide-the-separator-between-empty-cells refer this.. – iMash Jul 16 '14 at 10:39
  • possible duplicate of [Hiding UITableViewCell](http://stackoverflow.com/questions/2670635/hiding-uitableviewcell) – skyylex Jul 16 '14 at 11:15

1 Answers1

1

You need to change number of rows to the (previousNumber - 1) in this method

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

And to reload table:

 [tableView reloadData];

BTW: don't forget to implement such cases in the tableView:cellForRowForIndexPath: and in the tableView:heightForRowAtIndexPath: to return appropriate values.

skyylex
  • 855
  • 1
  • 10
  • 24
  • Thanks for your reply. That means that i delete the table or? What if i just want to hide it? The reason why is i have a table with a lot of answer possibilities - so if user (for example) selects Question 1 to "A" i will activate Question 3 and 4 (these are additional questions) - i thought the easiest way is to create the whole rows and just hide some on default and activate if needed. – derdida Jul 16 '14 at 12:39
  • 1
    It's work like you change the settings (numberOfRowsInSection will return other value) and apply them (by reloading). Reload data will just refresh the tableView, not to delete. – skyylex Jul 16 '14 at 12:44