Re: Custom view has a wrong accessibilityFrame at startup
Re: Custom view has a wrong accessibilityFrame at startup
- Subject: Re: Custom view has a wrong accessibilityFrame at startup
- From: Fritz Anderson <email@hidden>
- Date: Thu, 01 Dec 2011 13:46:49 -0600
On 1 Dec 2011, at 1:34 PM, Chris Fleizach wrote:
> How are you calculating the accessibilityFrame (please paste your code)
Thank you for your attention. Appended.
— F
- (void) updateAccessibilityElements
{
CGRect ownBounds = self.accessibilityFrame;
NSLog(@"%s: view accessibility frame = %@",
__PRETTY_FUNCTION__,
NSStringFromCGRect(ownBounds));
// This is wrong on runs pre-user-interaction (origin.y 20pt too big),
// correct thereafter.
NSUInteger count = [self.dataSource countForSegmentView: self];
// dataSource methods should be obvious.
// Drawing code that uses them works correctly.
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"];
totalTime += duration;
frameElem = [self rectForSegment: i];
// rectForSegment returns in view coordinates.
// There is no transform on the view bounds.
// The return value is used for drawing, which is correct in all cases.
frameElem = CGRectOffset(frameElem,
ownBounds.origin.x,
ownBounds.origin.y);
// Examining frameElem shows it to be reasonable.
elem.accessibilityFrame = frameElem;
}
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
nil);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden