views:

868

answers:

2

Hi,

In my iPhone application I have used (UITableViewCellAccessoryCheckmark) to add the checkmarks in the cells, - it is added to the cell at the right side of the cell.

I want the checkmarks to display in the middle of the cell and after that a string should display. So that the user can set the cell item as checked or unchecked.

Please provide any solution or any code for adding the (UITableViewCellAccessoryCheckmark) in the middle of the cell - would be appreciated.

Thanks,

Mishal Shah

+2  A: 

There is no built in way to do this. You will have to create a cell, then in tableView:cellForRowAtIndexPath: you will need to either add a custom subview, or return a custom cell and tell it to display the custom checkmark you added based on the data state.

coneybeare
+1  A: 

The accessory view of the cell is always on the right side, outside of the cell's content view (see the Table View Programming Guide for more on this). If you want to do something like this, you really need to create your own cell class, and draw the checks yourself.

Speaking as a user, this design seems sort of confusing, and definitely not what I'd expect. What's the string you're displaying to the right of the check? Maybe something like the UITableViewCellStyleValue1 style cell would work, instead? (See Standard Styles for Table-View Cells for more.)

Sixten Otto
Agreed that it's not something you'd normally want to do but I found one case where I needed to do it: I wanted to have both a checkmark and an alphabetical index on the right of the screen. I ended up using a custom view to put the check mark on the left.
Stephen Darlington