views:

346

answers:

2

I am using this style of table view UITableViewCellStyleValue2.

I set editing, but I cant seem to get the arrows to show up on the right of the cell - like the Contacts app.

Also in the contacts app I notice that if I have a Favorite it puts a * (star) to the right. Any info on how to get an image would be appreciated.

Thanks!

+2  A: 

You don't get the arrow on the right hand side by setting the editing - this is to set what happens if you click on an "edit" button at the top (eg drag & drop etc). What you're describing (from the reference to the Contacts app) is called a Disclosure indicator.

To get the arrow in the cell, put this in your tableView:cellForRowAtIndexPath method:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

There are other type of cell accessories - as you're typing the above in, stop before the "DisclosureIndicator" bit and press [esc] to see the choices.

Now, your second requirement - the star - is a bit more involved. This is because the framework doesn't come with the star image as a standard accessory.

Therefore you need to build an image, push it as a view onto the cell, and then set it to be its accessory view (or you could set its specific coordinates if you wanted). You'll have to make (or find) an image from somewhere else to use as the star.

Assuming you have an image called "myStar.png" the code (in the same method as above) would be:

UIImage *myImage = [UIImage imageNamed:@"myStar.png"];
[cell addSubview:myImage];
cell.accessoryView = myImage;

Like I said, that last line is optional - you could always set the specific co-ordinates of the image on the cell yourself.

Hope that helps!

h4xxr
A: 

You probably wanted the cell.editingAccessoryType property. This defines the style of arrow when in editing mode, and it should work fine.

Mike Weller