iOS: Cannot make debug messages disappear
iOS: Cannot make debug messages disappear
- Subject: iOS: Cannot make debug messages disappear
- From: Matthias Schmitt <email@hidden>
- Date: Mon, 11 Feb 2013 11:01:41 +0100
Hello,
I am implementing a custom UITableViewCell for implementing a "swipe to delete" button. Once the user swipes the cell I am adding the delete button as a subview to the contentView of the cell. This is working fine for visual users, but once I am testing this in VoiceOver, VoiceOver misses the button as a subview. Using
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, deleteButton);
the button is read once, but if I am moving the VO cursor back and forth, VO misses it again. So a visual disabled user cannot reach the delete button.
To enable VO to always find the delete button in the cell, I am implementing the UIAccessibilityContainer protocol. Now VO always finds the delete button and everything is working fine for visual enabled and disabled users. My problem: I am getting debug messages like this:
**** Accessibility: Could not find a valid index for <UITableViewCellContentView: 0x1e8fae10; frame = (10 1; 300 43); gestureRecognizers = <NSArray: 0x1e8fb000>; layer = <CALayer: 0x1e8fae70>> in -[PrefUITableViewCell indexOfAccessibilityElement:]
**** Accessibility: Could not find a valid index for <PrefUITableViewCell: 0x1e8fac80; baseClass = UITableViewCell; frame = (0 120; 320 45); autoresize = W; gestureRecognizers = <NSArray: 0x1d5fa2d0>; layer = <CALayer: 0x1e8fade0>> in -[UITableView indexOfAccessibilityElement:]
Even though I have an array 'accessibleElements' filled with the elements, which should get accessible, iOS calls the 'indexOfAccessibilityElement' method other objects than those in the 'accessibleElements' array. Now my questions:
- How can I make 'indexOfAccessibilityElement' be called only with those objects, which are in my 'accessibleElements' array?
- As everything is working right now, can I just ignore the debug message and continue? (I would prefer to not ignore these warnings, if possible.)
Here some code, so you have a chance to give some advice:
in my customised UITableViewCell:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
…
accessibleElements = [[NSMutableArray alloc] init];
}
- (void)dealloc {
[accessibleElements release];
…
}
- (BOOL)isAccessibilityElement
{
return NO;
}
- (NSInteger)accessibilityElementCount
{
return [self.accessibleElements count];
}
- (id)accessibilityElementAtIndex:(NSInteger)index
{
return [self.accessibleElements objectAtIndex:index];
}
- (NSInteger)indexOfAccessibilityElement:(id)element
{
return [[self accessibleElements] indexOfObject:element];
}
- (void)showDeleteButton
{
…
deleteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
…
[self.contentView addSubview:deleteButton];
[self.accessibleElements addObject:deleteButton];
…
}
in my UITableViewController
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
…
UILabel *txtLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 12.0, 130.0, 22.0)] autorelease];
…
[cell.contentView addSubview:txtLabel];
[cell.accessibleElements addObject:txtLabel];
UITextField *txtBalanceName = [balanceNameTextFields objectAtIndex:indexPath.section];
…
[cell.contentView addSubview:txtBalanceName];
[cell.accessibleElements addObject:txtBalanceName];
…
return cell;
}
This problem drives me crazy since three days. Please consider supporting my mental health. :-)
Best regards
Matthias Schmitt
magic moving pixel s.a.
23, Avenue Grande-Duchesse Charlotte
L-3441 Dudelange
Luxembourg
Phone: +352 54 75 75 - 0
http://www.mmp.lu
_______________________________________________
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