Permalink
Browse files

Work around accessibility API for table views so that we only see vis…

…ible cells.
  • Loading branch information...
Rob Holland
Rob Holland committed Jun 17, 2010
1 parent 4b3f2a0 commit 9b6573410627bcfec8fdb68dea5f5e2bf1d6b553
Showing with 38 additions and 2 deletions.
  1. +38 −2 ext/iCuke/sdk3.1/Viewer.m
View
@@ -1,9 +1,14 @@
+#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
#import "Viewer.h"
static Viewer *sharedViewer = nil;
+@interface NSObject (Accessibility)
+-(BOOL)_accessibilityIsFrameOutOfBounds;
+@end
+
@interface NSObject (UIAccessibilityViewer)
-(void)appendToXml:(NSMutableString*)xml;
@@ -115,9 +120,21 @@ -(void)appendToXml:(NSMutableString *)xml {
@end
+@implementation UITableView (AccessibilityVisibilityFix)
+
+-(void)appendChildrenToXml:(NSMutableString *)xml {
+ // Ignore the accessibility interface here because it doesn't allow us a way to tell if a cell is visible.
+ for (UIView *view in [self visibleCells]) {
+ [view appendToXml: xml];
+ }
+}
+
+@end
+
@interface UIView (Viewer)
-(void)appendToXml:(NSMutableString *)xml;
+-(void)appendFrameToXml:(NSMutableString *)xml;
@end
@@ -126,10 +143,12 @@ @implementation UIView (Viewer)
-(void)appendToXml:(NSMutableString *)xml {
[self appendOpenToXml: xml];
- if ([self isAccessibilityElement]) {
- [self appendFrameToXml: xml];
+ if ([self _accessibilityIsFrameOutOfBounds]) {
+ [xml appendFormat: @"<invisible/>"];
}
+ [self appendFrameToXml: xml];
+
for (UIView *view in self.subviews) {
[view appendToXml: xml];
}
@@ -138,6 +157,23 @@ -(void)appendToXml:(NSMutableString *)xml {
[self appendCloseToXml: xml];
}
+-(void)appendFrameToXml:(NSMutableString *)xml {
+ CGRect frame;
+
+ if ([self isAccessibilityElement]) {
+ frame = [self accessibilityFrame];
+ } else {
+ frame = [self frame];
+ }
+ [xml appendFormat: @"<frame x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>",
+ frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
+
+ frame = [[[UIApplication sharedApplication] keyWindow] convertRect:self.layer.visibleRect fromView:self];
+
+ [xml appendFormat: @"<visibleFrame x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>",
+ frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
+}
+
@end
@implementation Viewer

0 comments on commit 9b65734

Please sign in to comment.