ios8之后,使用UIAlertViw时pop/push页面后,键盘闪一下的问题

代码为ios

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感谢你对咱们提出的意见或建议,你的支持就是咱们进步的动力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil]; [alert show]; -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex==0) { [self backForward]; } }

效果如图动画

这是由于alertView的动画和键盘动画起冲突了
解决方法分为两种
①用UIAlertController,适用于ios8之后
②若仍是想用UIAlertView,那么能够用以下方法spa

alertview show的时候写个主线程延迟,pop也延迟线程

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感谢你对咱们提出的意见或建议,你的支持就是咱们进步的动力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [alert show]; });
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex==0) { [self performSelector:@selector(backForward) withObject:nil afterDelay:0.25f]; } }

好了的效果以下code

相关文章
相关标签/搜索