系统键盘在ios7 ios8上不同效果
来源:互联网 发布:手机登不了淘宝怎么办 编辑:程序博客网 时间:2024/05/29 11:50
今天写项目的时候遇到一个问题:从A界面推出B界面,B界面的textField编辑完成之后,向服务器发送编辑数据之后,成功之后弹出成功的系统提示框。代码如下:
//B界面的textfiled编辑完成点击okButton:
但这种情况在ios7 中没有出现,在ios8以上会出现:
- (void)OKButtonBeclick
{
__weakVFeedbackViewController *weakSelf = self;
[self.view endEditing:YES];
self.button.enabled =NO;
[[VFeedBackManagersharedManager] FeedBackWithcontent:self.feedbackTextView.textsuccess:^{
[UIAlertViewshowWithTitle:@"Thanks for your feedback" message:nilcancelButtonTitle:nil otherButtonTitles:@[@"OK"]tapBlock:^(UIAlertView *alertView,NSInteger buttonIndex) {
if (buttonIndex == 0) {
[weakSelf.navigationControllerpopViewControllerAnimated:YES];
}
}];
} failure:^(NSString *failing) {
weakSelf.button.enabled =YES;
NSLog(@"%@",failing);
}];
}
直接这样写的话会遇到一个问题:就是界面先返回,然后键盘会在A界面出现下落的状况。因为AlertView 的 block不是在主线程里面,所以会会执行先执行
[weakSelf.navigationController popViewControllerAnimated:YES]; 然后执行 [self.view endEditing:YES];
解决方案是进行延迟:等[self.view endEditing:YES]执行完毕,再执行AlertView 的 block 中得 [weakSelf.navigationController popViewControllerAnimated:YES];
延迟一段时间,等主线完成,待执行线程的函数
合理的代码是:加dispatch_after的延迟函数
- (void)OKButtonBeclick
{
__weakVFeedbackViewController *weakSelf = self;
[self.view endEditing:YES];
self.button.enabled =NO;
[[VFeedBackManagersharedManager] FeedBackWithcontent:self.feedbackTextView.textsuccess:^{
[UIAlertViewshowWithTitle:@"Thanks for your feedback" message:nilcancelButtonTitle:nil otherButtonTitles:@[@"OK"]tapBlock:^(UIAlertView *alertView,NSInteger buttonIndex) {
if (buttonIndex == 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.navigationControllerpopViewControllerAnimated:YES];
});
}
}];
} failure:^(NSString *failing) {
weakSelf.button.enabled =YES;
NSLog(@"%@",failing);
}];
}
- 系统键盘在ios7 ios8上不同效果
- ios7与ios8系统版本不同出现的问题积累
- KeyBoard 在iOS7和iOS8上通知的区别
- ios6应用运行在ios7系统上
- (七十五)CoreLocation(一)在iOS7和iOS8设备上获取授权
- iOS7 iOS8 调用系统通讯录界面
- 让app在ios6上具有ios7的扁平效果
- 让app在ios6上具有ios7的扁平效果
- 让app在ios6上具有ios7的扁平效果
- Bitmap.compress方法,在不同机器,不同系统上,保存出来的图片的效果和大小都会不一样
- ios7上实现UIVisualEffectView效果
- iOS8 Handoff实现在不同iOS设备上继续做同一件事
- iOS7 与 iOS8上 uisegementcontrol 设置image不显示问题
- iOS7 与 iOS8上 uisegementcontrol 设置image不显示问题
- UIActionSheet在IOS8上失效
- iOS8 系统键盘分析 ,与第三方键盘
- 如何在视图上显示不同效果的字体
- 测试一下pack()在不同layout上的效果
- pmfs 物理地址预分配
- windows平台下vlc编译之四:精简vlc
- Mac xampp
- “字号”“磅”“缇”“点”“毫米”“像素”的关系
- Gson解析内部类时报can not access a member of class xxx with modifiers "final"
- 系统键盘在ios7 ios8上不同效果
- 学习日记java 泛型和泛型类
- Linux-常用的20条命令
- 对C++中虚成员函数的理解
- Random Forest随机森林算法
- 二元树的生成、遍历、以及最短最长路径查询
- OSPF的几个关键参数
- 关于vs2010 中c++输出字符串到txt文件中的格式问题
- 2-20