accessoryType in the left side - iphone

Is there any way to set the accessoryType of the cell to be in the left side?
the code i use:
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
in this condition the accessoryType button is on the right side and i want it in the left side.
I tried also to build a custom cell be in the IB when i chose accessory it put it automatic in the right side also.

No, but you can set the cell's imageView.image property to a UIImage of your choice.
If you re-use Apple's disclosure button images, you might run into issues getting your app accepted, so you might want to create your own disclosure icons.

Related

UITableViewCell design changes when selecting

When I select a cell using the cell selection button , the design of the cell changes.
There is a blue line in the bottom (may be due to selection highlighting)
and the round corner changes to light blue.
Please suggest ways to solve this issue. I don't want these two effects.
Try something like this:
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

UITableViewCellSelectionStyleNone whilst still showing checkmark in edit mode

I am having issues setting the cell background colour on a grouped table cell when in edit mode. It seems to get the checkmark to appear a selection style has to be set and the only options are UITableViewCellSelectionStyleBlue or UITableViewCellSelectionStyleGray.
What I am after is the for the checkmark just to be selected and the cell remain white when it is checked.
You would have thought UITableViewCellSelectionStyleNone would have this behaviour but this stops the checkmark for showing.
I have tried to use setSelectedBackgroundView. This would work if the cell style was not grouped but as it is the round corners do not get drawn.
The properties for the cell above are
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.backgroundView = [self tableViewCellRowBackground];
Where tableViewCellRowBackground is a UIView with orange background.
The editMode is the built in iOS table edit mode with the following properties set on the table
self.tblFiles.allowsSelectionDuringEditing=YES;
self.tblFiles.allowsMultipleSelectionDuringEditing = YES;
Any ideas?
cell.backgroundView = [self tableViewCellRowBackground];
This method is setting an image for your selected cell.You should check out this one to make the selection Style image nil.
In the end I had to create my own custom cells by overriding the drawrect method.

Can I stop a cell's disclosure indicator from turning white when selected?

I have a cell where the accessory type is set to a disclosure indicator via:
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
Now when selected, it turns white as per default.
Because I have changed the default selection style/view via the cell's 'backgroundView' and 'selectedBackgroundView' properties, I want the disclosure indicator to stay gray as it will look better.
Is there an easy way to do this without having to create a custom disclosure indicator image and adding this to the cell?
Try this link:Custom colored disclosure indicators
I would subclass UITableViewCell and override -setHighlighted:animated: and -setSelected:animated. In these methods, you set the accessoryType to UITableViewCellAccessoryNone. From here all you need to do is add a gray disclosure indicator to your selectedBackgroundView.

UITableViewCellStyleValue2 edit indicators?

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!
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!
You probably wanted the cell.editingAccessoryType property. This defines the style of arrow when in editing mode, and it should work fine.

How to add UITableViewCellAccessoryCheckmark in the middle of the cell in iphone?

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.
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.
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.)