Almazini Almazini - 4 months ago 22
iOS Question

disclosure indicator out of custom cell bounds

I have a custom cell with enabled disclosure indicator. Enabled throw the code in cellForRowAtIndexPath method:

cell.accessoryType = .DisclosureIndicator


To create an illusion of space between cells I have created a UIImage inside my cell.

I was expecting that disclosure will be inside new cell but it is not.

My layout setup :

enter image description here

and how it looks like:

enter image description here

Can anybody suggest what I am doing wrong here?

Answer

I was expecting that disclosure will be inside new cell but it is not.

It is inside cell, but it seems outside to you coz it is outside image view.

We need to extend the image view below disclosure indicator.
I did a simple trick of setting leading space constraint to negative value as:

enter image description here

(Above are the constrains of green view, in your case image!)

I also added disclosure indicator from .xib instead of code as:

enter image description here

In .xib it will show like above picture, but it works when we run as: enter image description here

Instead of adding image, I've added UIView with green colour, this is just to implement faster.
You can do same with UIImageView.