iOS5里面遇到的兼容性问题以及解决方法

 

iOS5新版本一正式发布,马上就有客户反映问题了,这里是论坛会员总结的出现的一些兼容性问题和给出的一些解决方法,本文会随着帖子持续更新,大家可以去论坛参与讨论。

 

以下问题和解决方法供大家参考:

某些界面不显示,定制键盘不正常。
界面问题,原来是有些界面控件的行为改变了;
1)比如说:UISegmentedControl,
[segmentControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
原来segmentControl.selectedSegmentIndex = 0;这样的调用会导致直接调用一次segmentAction。
但是在ios5中没有调用。要手动去执行一下,可以这样改,在设置完selectedSegmentIndex以后,加上
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
[self segmentAction:segmentControl];
}
2)非pad界面的数字键盘,自定义增加一个ok按钮,在ios4上可以正确执行的,ios5上也不行了
比如说这个:http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key
经改进如下可以执行在ios5上正常显示

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard view found; add the custom button to it
if(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES)||[[keyboard description] hasPrefix:@"<UIKeyboard"] == YES){
CGRect frame = CGRectMake(0.0f, 162.0f, 106.0f, 53.0f);
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight)){
frame = CGRectMake(0.0f, 116.0f, 162.0f, 53.0f);
}
[doneBt setFrame:frame];
[keyboard addSubview:doneBt];
break;
}
}

3)uiviewcontroller的- (void)viewWillAppear:(BOOL)animated方法,显示或者隐藏的时候都被调用。
而- (void)viewWillDisappear:(BOOL)animated从不被调用了

4)UINavigationBar的背景自定义图片
要实现navigationBar的背景自定义图片,是直接定义一个UINavigationBar的category,并重写drawRect方法,在ios5下面,navigationBar的drawRect方法似乎都不被调用了。
解决方法是:在app delegate里面的application didFinishLaunchingWithOptions方法中,加入
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"xxx.png"] forBarMetrics:UIBarMetricsDefault];

5)ios5的键盘尺寸
ios5的键盘尺寸不再固定为以前的216,而是有216和252两种。比如说英文键盘的尺寸是216,而中文拼音键盘的尺寸是252,切换输入法之类的操作都可能会引起键盘尺寸的变化,所以随时要注意键盘上面多出的那一块会不会把用户界面给挡掉,更具体的情形,可以看我在这里的回复
http://www.cocoachina.com/bbs/read.php?tid=77630&page=2#457640

6)自定义的UIView在使用UIScrollView的时候,ios4下,拖动滚动的时候,会不断调用layoutSubviews这个方法。
但是在ios5里面经常不调用,需要自己增加如下一个方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
[self setNeedsLayout];
}
}

 

7)关于UITableView的IndexPath  超级常用 为了记录展开的的cell 加了个属性expendIndexPath
当点击某个cell时直接self.expendIndexPath = IndexPath
结果ios5 中 判断时
if (self.expendIndexPath == IndexPath)  {
     //ios4 走, 但ios5 不走
}
改为对应的row = row  section = section

 

iOS5兼容性问题集中讨论帖:http://www.cocoachina.com/bbs/read.php?tid-78406.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值