iOS SDK 6.1的UITableView与iOS SDK 5.1不兼容 [英] UITableView of iOS SDK 6.1 don't compatible with iOS SDK 5.1

查看:76
本文介绍了iOS SDK 6.1的UITableView与iOS SDK 5.1不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用iOS 6.1 SDK在XCode 4.6中创建了UITableView项目,并将目标sdk设置为5.1,当应用程序在cellForRowAtIndexPath函数中调用dequeueReusableCellWithIdentifier时,该应用程序抛出异常,模拟器为5.1,模拟器6.x可以.

1: [UITableView dequeueReusableCellWithIdentifier:forIndexPath:]:无法识别的选择器发送到实例

2:由于未捕获的异常NSInvalidArgumentException而终止应用程序,原因:-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]:无法识别的选择器发送到实例

解决方案

如果查看Apple文档,您会看到dequeueReusableCellWithIdentifier:"调用(如果可能).

这两个调用之间的一个很大区别是,后者(较旧)一个可以返回nil,在这种情况下,您需要分配/初始化一个新的可重用单元格.

I have created UITableView project in XCode 4.6 with iOS 6.1 SDK, and set target sdk to 5.1, when the app calling dequeueReusableCellWithIdentifier in cellForRowAtIndexPath function, the app throw a exception, the simulator is 5.1, on simulator 6.x is ok.

1: [UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance

2:Terminating app due to uncaught exception NSInvalidArgumentException, reason: -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance

解决方案

If you look at the Apple documentation, you'll see that dequeueReusableCellWithIdentifier: forIndexPath: came in with iOS 6.0.

That means if you try to call this method on iOS 5.X devices, it's going to throw an exception.

It would be better if you used the older "dequeueReusableCellWithIdentifier:" call if possible.

One big difference between the two calls is that the latter (older) one can return nil, in which case you need to alloc/init a new reuseable cell.

这篇关于iOS SDK 6.1的UITableView与iOS SDK 5.1不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆