From fc27b3da51bf7954a734dbaae87bc7bc973fee2d Mon Sep 17 00:00:00 2001 From: Rafael Nobre Date: Tue, 23 Aug 2016 17:55:32 -0300 Subject: [PATCH] Fixes iPad accessibility --- REMenu/REMenu.m | 9 +++++++++ REMenu/REMenuItemView.m | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/REMenu/REMenu.m b/REMenu/REMenu.m index 9d0c367..a37cf3e 100644 --- a/REMenu/REMenu.m +++ b/REMenu/REMenu.m @@ -44,6 +44,7 @@ @interface REMenu () @property (strong, readwrite, nonatomic) NSMutableArray *itemViews; @property (weak, readwrite, nonatomic) UINavigationBar *navigationBar; @property (strong, readwrite, nonatomic) UIToolbar *toolbar; +@property (strong, nonatomic) UIView *firstItem; @end @@ -218,12 +219,17 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view [itemView addSubview:item.customView]; } [self.menuView addSubview:itemView]; + if (!self.firstItem) { + self.firstItem = itemView; + } } // Set up frames // self.menuWrapperView.frame = CGRectMake(0, -self.combinedHeight - navigationBarOffset, rect.size.width, self.combinedHeight + navigationBarOffset); + self.menuView.autoresizesSubviews = NO; self.menuView.frame = self.menuWrapperView.bounds; + self.menuView.autoresizesSubviews = YES; if (REUIKitIsFlatMode() && self.liveBlur) { self.toolbar.frame = self.menuWrapperView.bounds; } @@ -264,6 +270,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view if ([self.delegate respondsToSelector:@selector(didOpenMenu:)]) { [self.delegate didOpenMenu:self]; } + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.firstItem); }]; } else { [UIView animateWithDuration:self.animationDuration @@ -279,6 +286,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view if ([self.delegate respondsToSelector:@selector(didOpenMenu:)]) { [self.delegate didOpenMenu:self]; } + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.firstItem); }]; } @@ -296,6 +304,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view if ([self.delegate respondsToSelector:@selector(didOpenMenu:)]) { [self.delegate didOpenMenu:self]; } + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.firstItem); }]; } } diff --git a/REMenu/REMenuItemView.m b/REMenu/REMenuItemView.m index bf2e5c6..18ad061 100644 --- a/REMenu/REMenuItemView.m +++ b/REMenu/REMenuItemView.m @@ -69,7 +69,7 @@ - (id)initWithFrame:(CGRect)frame menu:(REMenu *)menu item:(REMenuItem*) item ha }); [self addSubview:_subtitleLabel]; } else { - titleFrame = CGRectMake(self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.width : self.item.textOffset.width, self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.height : self.item.textOffset.height, 0, frame.size.height); + titleFrame = CGRectMake(self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.width : self.item.textOffset.width, self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.height : self.item.textOffset.height, frame.size.width, frame.size.height); } _titleLabel = ({