iOS8.1- iOS8.3横屏后部分区域无响应bug 解决办法
2017-07-10 16:57
483 查看
注意通过[[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:YES];来设置屏幕旋转会导致
iOS version 8.1 ~ iOS version 8.3 之间的版本在横屏时出现home键后半部没有响应的情况。
对于点击事件会导致点击的坐标点不正确,但是对于滑动等手势不会造成影响,滑动拖动等手势一般都是根据相对位移来进行判断的。而点击事件大多都是根据绝对坐标进行判断的。
如果因为使用[[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:YES]来旋转屏幕会出现iOS8.1-iOS8.3下出现home键后半部不响应点击事件的情况,而改用[[UIDevice
currentDevice] setValue:rotation forKey:@"orientation"]来解决问题,就会出现顶部状态条不能跟随屏幕方向发送改变,另外对于键盘,声音大小的弹框等都不会更加设备的当前方向自动调整,就需要手动设置这些控件,特别是顶部状态条,在全屏下必须隐藏,这个可能会和设计的需求不一致。在iOS8.1-iOS8.3下解决不响应问题的方法为:
重写hitTest方法将hitTest的坐标点转移到具有点击事件的视图上。
具体的内容可以看考demo:点击打开链接
关键部分为:
iOS version 8.1 ~ iOS version 8.3 之间的版本在横屏时出现home键后半部没有响应的情况。
对于点击事件会导致点击的坐标点不正确,但是对于滑动等手势不会造成影响,滑动拖动等手势一般都是根据相对位移来进行判断的。而点击事件大多都是根据绝对坐标进行判断的。
如果因为使用[[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:YES]来旋转屏幕会出现iOS8.1-iOS8.3下出现home键后半部不响应点击事件的情况,而改用[[UIDevice
currentDevice] setValue:rotation forKey:@"orientation"]来解决问题,就会出现顶部状态条不能跟随屏幕方向发送改变,另外对于键盘,声音大小的弹框等都不会更加设备的当前方向自动调整,就需要手动设置这些控件,特别是顶部状态条,在全屏下必须隐藏,这个可能会和设计的需求不一致。在iOS8.1-iOS8.3下解决不响应问题的方法为:
重写hitTest方法将hitTest的坐标点转移到具有点击事件的视图上。
具体的内容可以看考demo:点击打开链接
关键部分为:
+ (BOOL)isNeedAdaptiveiOS8Rotation{ NSArray<NSString *> *versionStrArr = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; NSLog(@"versionArr is %@", versionStrArr); int firstVer = [[versionStrArr objectAtIndex:0] intValue]; int secondVer = [[versionStrArr objectAtIndex:1] intValue]; if (firstVer == 8) { if (secondVer >= 1 && secondVer <= 3) { return YES; } } return NO; } /** //对于iOS8.1 - iOS8.3版本使用 [[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:YES]; 导致home键后半部点击区域不响应的解决办法。 */ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{ BOOL isNeedAdaptiveiOS8 = [[self class] isNeedAdaptiveiOS8Rotation]; UIInterfaceOrientation currentInterfaceOrientation = [UIApplication sharedApplication].statusBarOrientation; //对于iOS8.1 - iOS8.3版本 当点击按钮位于home键的下半区域时不响应点击事件,因此只需要处理不响应的情况即可 BOOL isNeedJudge = currentInterfaceOrientation == UIInterfaceOrientationLandscapeRight; if (isNeedAdaptiveiOS8 && isNeedJudge) { CGPoint btnPoint = [self convertPoint:point toView:self.clickBtn]; if ([self.clickBtn pointInside:btnPoint withEvent:event]) { //点击区域在clickBtn上 __weak typeof(self) weakSelf = self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.11 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf clickBtnAction:self.clickBtn]; }); weakSelf.userInteractionEnabled = NO; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ weakSelf.userInteractionEnabled = YES; }); return self.clickBtn; } } return [super hitTest:point withEvent:event]; }
相关文章推荐
- iOS8.1- iOS8.3横屏后部分区域无响应 坐标错乱
- iOS8之后只支持竖屏的App中某个界面强制横屏后导致部分区域无响应
- 部分无线终端不响应键盘事件(keydown,keypress,keyup)的解决办法
- eclipse在新版本GTK(2.18) 上的一个bug--鼠标点击按钮无响应的解决办法
- Unity UGUI 不规则按钮 响应区域重叠的解决办法
- eclipse在新版本GTK(2.18) 上的一个bug--鼠标点击按钮无响应的解决办法
- RichEdit控件在处理EM_REPLACESEL消息中有bug?附一种解决办法
- 跨时间区域显示相应区域时间的解决办法
- VSTS有Bug,分析数据库的维度和维度属性使用中文命名时候,作为报表参数会出错。虽然有解决办法但是头大。
- "必须输入正文"BUG的解决办法!
- 解决K700真机左右软键无响应Bug
- 关于部分Vista驱动丢失的解决办法
- 解决K700真机左右软键无响应Bug
- 解决K700真机左右软键无响应Bug
- 解决K700真机左右软键无响应Bug
- 解决K700真机左右软键无响应Bug
- Indy10线程池BUG:Idyarn线程使用Synchronize导致TerminateAllYarns挂死的解决办法
- 飘云QQ2007现有BUG解决办法...终于搞定!
- Ie浏览器double margin bug 解决办法
- 提示“打印机无响应” 解决办法