dequeueReusableCellWithIdentifier error in my UITableView in iOS5(iOS5 中我的 UITableView 中的 dequeueReusableCellWithIdentifier 错误)
问题描述
我在 iOS 5 中遇到此错误
I am getting this error in iOS 5
-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]:无法识别的选择器发送到实例0xa217200
但是,我在 iOS 6 中没有遇到任何错误.我该如何解决这个问题?这是我的代码:
However, I get no errors in iOS 6. How can I fix this problem? Here's my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; /// SIGABRT error
if (!cell)
{
cell = [[UITableViewCell alloc]
initWithStyle: UITableViewCellStyleSubtitle
reuseIdentifier: CellIdentifier];
}
return cell;
}
推荐答案
EDIT:这个方法是iOS6+ SDK新增的.
EDIT: This method is newly added in iOS6+ SDK.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
但在 iOS 5 中,创建 UITableViewCell 的实例我们通常使用这种方法:-
But in iOS 5, to create instance of UITableViewCell we generally use this method :-
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
在 iOS 5 中,不需要你在 iOS 6 中使用的额外参数.(forIndexPath:).
In iOS 5, there is no need of extra parameter which you have used in iOS 6. (forIndexPath:).
所以改变你的方法.它会起作用的.
So change your method. It will work.
这篇关于iOS5 中我的 UITableView 中的 dequeueReusableCellWithIdentifier 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS5 中我的 UITableView 中的 dequeueReusableCellWithIden
基础教程推荐
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
