This issue is seriously perplexing me. I have a small UIView I'm using to show which button is selected. However, it's not showing up in my app — it should be under "Local Activities," but doesn't show up:
That's fine, I thought, I'll just debug the view hierarchy and see where it is! And it looks like it's exactly where it should be:
Does anyone know what might be going on here? Thanks for the help!
I have found what was causing this.
I programmatically created two subviews (Subview A and Subview B) inside a view controller; neither of which appeared on my device even though the frames' size and positions, alpha values, and all the other usual visibility issues all checked out. Subview A was a subview of the view controller's view, and Subview B was a subview of Subview A. Neither were visible on my device, but when I looked in the View Debugger Hierarchy I was able to see Subview B (even though its superview, Subview A, was not visible).
Long story short, the issue was fixed when I removed code that was altering Subview A's layer's mask property. Here's the exact method that was being called on the layer:
extension CALayer { func round(corners: UIRectCorner, withRadius radius: CGFloat, withBounds: CGRect? = nil) { let path = UIBezierPath(roundedRect: withBounds ?? bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) let mask = CAShapeLayer() mask.path = path.cgPath self.mask = mask } }
I've used this method in the past with no issues so I'm sure the problem was somewhat circumstantial but maybe this will point someone in the right direction in the future.
The issue wasn't just the code shown above but the fact that I was changing Subview A's frame after calling round(). Once I made sure to only round() Subview A after it had been given its final position and size, all issues with both device and debugger were solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With