Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accessibility

Accessibility for Calendar View.

Signed-off-by: mikevpark <mikevpark@hotmail.com>
  • Loading branch information...
commit abed7380b8a735ec1ecc808453e6b47a6b7cf42f 1 parent 6c1d9a8
Mike Park authored
Showing with 41 additions and 1 deletion.
  1. +41 −1 src/TapkuLibrary/TKCalendarMonthView.m
42 src/TapkuLibrary/TKCalendarMonthView.m
View
@@ -142,6 +142,7 @@ @interface TKCalendarMonthTiles : UIView {
BOOL startOnSunday;
}
@property (strong,nonatomic) NSDate *monthDate;
+@property (nonatomic, strong) NSMutableArray *accessibleElements;
- (id) initWithMonth:(NSDate*)date marks:(NSArray*)marks startDayOnSunday:(BOOL)sunday;
- (void) setTarget:(id)target action:(SEL)action;
@@ -166,12 +167,43 @@ @interface TKCalendarMonthTiles (private)
@implementation TKCalendarMonthTiles
@synthesize monthDate;
+#pragma mark - Accessibility Container methods
+
+- (NSArray *)accessibleElements
+{
+ if (_accessibleElements != nil)
+ {
+ return _accessibleElements;
+ }
+
+ _accessibleElements = [[NSMutableArray alloc] init];
+
+ return _accessibleElements;
+}
+
//The container itself is not accessible
- (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];
+}
+
+#pragma mark - Init Methods
+
+ (NSArray*) rangeOfDatesInMonthGrid:(NSDate*)date startOnSunday:(BOOL)sunday{
NSDate *firstDate, *lastDate;
@@ -351,7 +383,15 @@ - (void) drawTileInRect:(CGRect)r day:(int)day mark:(BOOL)mark font:(UIFont*)f1
alignment: UITextAlignmentCenter];
}
-
+ //Set Accessibility
+ UIAccessibilityElement *tileElement = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:self];
+ tileElement.accessibilityFrame = [self convertRect:r toView:nil];
+ tileElement.accessibilityLabel = str;
+ tileElement.accessibilityValue = mark ? @"Activities" : @"No Activities";
+ tileElement.accessibilityTraits = UIAccessibilityTraitUpdatesFrequently;
+
+ [_accessibleElements addObject:tileElement];
+
}
- (void) drawRect:(CGRect)rect {
Please sign in to comment.
Something went wrong with that request. Please try again.