UITableViewCell with custom disclosure causes mis-alignment?

My guess is its because you are using content mode left in the UIImageView. Use content mode center.

Up vote 0 down vote favorite share g+ share fb share tw.

I hope someone reading this might be able to shed some light on this problem. I have a plain UITableView containing custom UITableViewCells, each cell is a different height provided by tableView:heightForRowAtIndexPath: and the table does not scroll. The cells themselves are really containers for one or two UILabels nothing very special.

Three of the cells show a custom disclosure when editing apart from that no disclosures are used for anything else. The custom disclosures are UIImageView's assigned to the cells editingAccessoryView with 28x29 images however the UIImageView size is set to 40x29 to give a better position using contentMode Left. This should work fine but what happens is when the disclosures appear in edit mode they don't all share the same position - two might be the same x and the third might be 5px different.

This seems to be dependant on the height given to each cell, they basically move around. I can't see how they are associated but have found one set of heights that give the expected results of all three being in the same position. This isnt ideal but has been working fine till now - I have no choice but to change the heights and so the alignment is a big problem.

If I remove the custom disclosures then the standard disclosures work perfectly? I've tried lot's of things, i.e. Removing the extra width on the UIImageView reducing the size of the image playing around with the cell heights - the disclosures just move around replacing the UIImageView's with other controls - no difference If you have any ideas why this might be I'd love to here them, thanks.

Iphone cocoa-touch uitableview uitableviewcell link|improve this question edited Nov 10 '10 at 15:03 asked Nov 10 '10 at 14:57John S. Eddie594.

I have since realised that this problem occurs when all the cells displaying a disclosure do not have the same height but other cells can be any height. I have managed to add in other "blank" cells to format the table as I require. Given I have no problems using the standard disclosures I suspect this is a bug.

– John S. Eddie Nov 11 '10 at 17:15.

My guess is its because you are using content mode left in the UIImageView. Use content mode center. The views get stretched in all directions when the height changes, but the image stays on the left edge of the view...

I've already tried changing the additional width I have added and the contentMode, sadly this doesn't solve the problem. – John S. Eddie Nov 10 '10 at 20:39 My understanding is that editingAccessoryView will set the size of your UIImageView - ignoring what you have initialised it to.

So, Changing the size of the image view will make no difference. Another way to do this would be to use a container UIView that you add your UIImageView to, that has autoResizeSubviews set to NO. If the image still moves around, you can reset its position within the container view (subclass and override UITableViewCell layoutSubviews) – Nick H247 Nov 11 '10 at 8:51 thanks for your thoughts.

The width change works, I can change it to what I want and I can see the change, if I have all the cells at the same height I don't have a problem. It's when I change the heights of some of the cells that the problems appears. – John S.

Eddie Nov 11 '10 at 17:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions