Improve debugging with Capture View Hierarchy

This commit is contained in:
Kylmakalle
2025-11-18 23:17:22 +02:00
parent b8b777b611
commit dc57b1da0a

View File

@@ -75,6 +75,10 @@ static _ASDisplayViewMethodOverrides GetASDisplayViewMethodOverrides(Class c)
{
BOOL _inHitTest;
BOOL _inPointInside;
#pragma mark - Swiftgram
#if DEBUG
NSString *_as_debugAccessibilityLabel;
#endif
NSArray *_accessibilityElements;
CGRect _lastAccessibilityElementsFrame;
@@ -152,6 +156,37 @@ static _ASDisplayViewMethodOverrides GetASDisplayViewMethodOverrides(Class c)
#pragma mark - UIView Overrides
#pragma mark - Swiftgram
#if DEBUG
- (NSString *)accessibilityLabel
{
NSString *existing = [super accessibilityLabel];
if (existing.length > 0) {
return existing;
}
// Reuse cached value if we already computed it
if (_as_debugAccessibilityLabel.length > 0) {
return _as_debugAccessibilityLabel;
}
ASDisplayNode *node = _asyncdisplaykit_node;
if (!node) {
return nil;
}
if (node.debugName.length > 0) {
_as_debugAccessibilityLabel = node.debugName;
return _as_debugAccessibilityLabel;
}
// Fallback computed once per view
_as_debugAccessibilityLabel = ASObjectDescriptionMakeTiny(node);
return _as_debugAccessibilityLabel;
}
#endif
- (void)willMoveToWindow:(UIWindow *)newWindow
{
ASDisplayNode *node = _asyncdisplaykit_node; // Create strong reference to weak ivar.