How do I use `readableContentGuide` with an accessory in a custom cell?

I created my own subclass UITableViewCell

. I want to align the edges of my subset with anchors readableContentGuide

:

let guide = contentView.readableContentGuide
myView.leadingAnchor.constraint(equalTo: guide.leadingAnchor).isActive = true

      

enter image description here

This works as expected until I add an additional view that will disable the layout.

accessoryType = .discloseIndicator

      

enter image description here

In default cells, the layout works correctly:

enter image description here

I'm curious to know if this is a UIKit bug or if I have another way to do this?

I came up with a workaround where I attach my subtitle to the default text label, which seems to work, but of course I would prefer.

textLabel?.text = " "
myView.leadingAnchor.constraint(equalTo: textLabel!.leadingAnchor).isActive = true

      

enter image description here

ps: blue border displays frame cell.contentView

(via View debugger)

+3


source to share





All Articles