On 1 Dec 2011, at 1:55 PM, Chris Fleizach wrote: You still need to convert the frame to the window... This assumes that framElem starts out being the coordinate space of the view itself. So
First manipulate it to get the size of the object in the coordinate space of the view.
CGRect frameElem = self.bounds; // assumes object is half width of real object frameElem.size.width = framElem.size.width/2;
// now convert to window space
UIWindow *window = [self window]; frameElem = [view convertRect:frameElem toView:window]; frameElem = [window convertRect:frameElem toWindow:nil]; elem.accessibilityFrame = frameElem;
I renew my question. I tried what you suggested, and it doesn't work. Exactly the same error occurs: The accessibility frames are origin.y+20 offset from their correct positions.
I think it's screwing up my hit-tests on touch events as well.
All problems clear if I redraw the problem view (after putting up and tearing down a near-full-screen image view, and using an AVAudioRecorder). There are no problems whatsoever with drawing code, and no problems if accessibility is off.
I append my code.
Again: What's my next step? Do you have advice? Should I file a bug? Do I have to burn a DTS incident?
Or do I have to abandon accessibility altogether? That's going to be trouble, as my institution takes accessibility seriously, and I'll be disappointed if I can't do the right thing. But if it's not technically feasible, they'll take my word for it, and hope we don't get sued.
Xcode 4.2, iOS SDK 5.0, targeting iOS 4.3, error manifests on simulator 4.3 and device 5.0, ARC.
— F - (void) updateAccessibilityElements
{
NSUInteger count = [self.dataSource
countForSegmentView: self];
UIAccessibilityElement * elem;
CGRect frameElem;
double totalTime = 0.0;
self.accArray = [NSMutableArray arrayWithCapacity: count];
for (int i = 0; i < count; i++) {
elem = [[UIAccessibilityElement alloc]
initWithAccessibilityContainer: self];
[self.accArray addObject: elem];
double duration;
BOOL isMaster;
duration = [self.dataSource segmentView: self
durationForSegmentAtIndex: i
isMaster: &isMaster];
elem.accessibilityLabel = [NSString stringWithFormat:
@"%s segment, %.1f seconds at %.1f, %s",
isMaster? "Master": "Student",
duration, totalTime,
[self.selectedSegmentSet containsIndex: i]?
"selected": "not selected"];
elem.accessibilityHint =
@"Double-tap to select, triple-tap to move here.";
totalTime += duration;
frameElem = [self rectForSegment: i];
// rectForSegment: derives a CGRect from self.bounds.
frameElem = [self convertRect: frameElem toView: self.window];
frameElem = [self.window convertRect: frameElem toWindow: nil];
elem.accessibilityFrame = frameElem;
}
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
nil);
}
|