Skip to content

Instantly share code, notes, and snippets.

@douglashill
Created January 19, 2014 09:47
Show Gist options
  • Save douglashill/8502588 to your computer and use it in GitHub Desktop.
Save douglashill/8502588 to your computer and use it in GitHub Desktop.
iOS: log UIAccessibility related properties
//
// NSObject+AccessibilityInspect.h
// Created by Douglas Hill on 29/09/2012.
//
#import <Foundation/Foundation.h>
@interface NSObject (AccessibilityInspect)
- (void)logAccessibiltyProperties;
@end
//
// NSObject+AccessibilityInspect.m
// Created by Douglas Hill on 29/09/2012.
//
#import "NSObject+AccessibilityInspect.h"
@implementation NSObject (AccessibilityInspect)
- (void)logAccessibiltyProperties
{
NSLog(@"Accessibilty properties for %@", self);
NSLog(@"- - - - - - - - - - - - - - - - - - - -");
NSLog(@"Activation Point: %@", NSStringFromCGPoint([self accessibilityActivationPoint]));
NSLog(@"Elements Hidden: %c", [self accessibilityElementsHidden]);
NSLog(@"Frame: %@", NSStringFromCGRect([self accessibilityFrame]));
NSLog(@"Hint: %@", [self accessibilityHint]);
NSLog(@"Label: %@", [self accessibilityLabel]);
NSLog(@"Language: %@", [self accessibilityLanguage]);
NSLog(@"Traits: %llu", [self accessibilityTraits]);
NSLog(@"Value: %@", [self accessibilityValue]);
NSLog(@"View Is Modal: %c", [self accessibilityViewIsModal]);
NSLog(@"- - - - - - - - - - - - - - - - - - - -");
NSInteger count = [self accessibilityElementCount];
if (count == NSIntegerMax) {
NSLog(@"Accessibility element count is NSIntegerMax");
return;
}
NSLog(@"Accessibility element count: %d", count);
for (int index = 0; index < count; index++) {
NSLog(@"Accessibility Element At Index %d: %@", index, [self accessibilityElementAtIndex:index]);
}
NSLog(@"- - - - - - - - - - - - - - - - - - - -");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment