0

Bit of background of the app I'm currently writing. It's a tableview and when a cell is tapped it loads a local HTML page.

However, now I'd like to implement section headers, a section header for complete and incomplete. The default header would be incomplete and after an interaction on the table view by a user, the cell is moved to complete. An option would be required to reverse the change should the change be done by mistake.

My first thought was to put in a check box in each cell, checking the box would move the cell and unchecking would move it back but I see iOS offers no such function, instead using switches instead.

For my needs, switches wouldn't work very well. So I'd like to ask others thoughts on this and how to implement such a thing, if anything.

Any thoughts or help appreciated.

Thanks.

mattFllr
  • 233
  • 7
  • 23
  • 2
    So which part you confused? [Creating a section header](http://stackoverflow.com/questions/10505708/how-to-set-the-uitableview-section-title-programmatically-iphone-ipad) or [moving one row from one section to another](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/moveRowAtIndexPath:toIndexPath:) or [creating a check box](http://stackoverflow.com/a/5368301/1730272) – iDev Dec 05 '12 at 22:42
  • Why can't you have a checkbox? Create a custom view for your needs then add it to the accessory view of the cell. Since it's just a UIView, you can add buttons. if you want to customize more just subclass a uitableviewcell and add whatever you need there. – mkral Dec 05 '12 at 22:42

1 Answers1

0

You can implement a check mark using this approach. Basically you need to add a button on the cell and change its background image to show selected and deselected state. You can also consider using the default accessory check mark feature in tableview cell.

For eg:-

cell.accessoryType = UITableViewCellAccessoryCheckmark;

and

cell.accessoryType = UITableViewCellAccessoryNone;

In order to implement the section header, you can use - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section method or viewForHeaderInSection: method.

You can move a cell from one section to another one using the below method,

- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
Community
  • 1
  • 1
iDev
  • 23,310
  • 7
  • 60
  • 85
  • Thanks. I didn't even know that table method existed! Definitely something to look into. Although wouldn't using the check mark go against the HIG? I was under the impression a disclosure indicator accessory was needed if tapping a cell presented more info or another view? Maybe a button and an indicator in a custom cell? I think that's the bit that's getting me, don't want to invest the time if it's only going to be rejected by Apple. Might be worth mentioning I'm still new at this. :) – mattFllr Dec 06 '12 at 18:56
  • @mattFllr, So which one do you feel that against apple HIG? If possible, you can use `UITableViewCellAccessoryCheckmark`. That is the default check mark in table. But if you need a custom check mark in place of accossoryview, apple wont reject that too. I have seen a lot of apps with custom check marks. There is nothing against HIG. – iDev Dec 06 '12 at 18:59
  • @mattFllr, Hope you are aware that `UITableViewCellAccessoryCheckmark` is not same as a disclosure indicator. That is a different accessorytype you are referering. This one is used for the purpose mentioned in your question only. – iDev Dec 06 '12 at 19:10
  • Yeah, I think I've got it. Thank you. :) – mattFllr Dec 06 '12 at 20:32