Error dequeueReusableCellWithIdentifier in my UITableView in iOS5

I get this error in iOS 5

-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance 0xa217200

However, I see no errors in iOS 6. How can I fix this problem? Here is 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; } 
+48
ios uitableview ios5 ios6
Aug 18 '12 at 6:13
source share
2 answers

EDIT : This method has recently been added to the iOS6 + SDK.

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

But in iOS 5, we usually use this method to create an instance of UITableViewCell : -

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

In iOS 5, there is no need for an additional parameter that you used in iOS 6. (forIndexPath :).

So change your method. He will work.

+129
Aug 18 '12 at 6:26
source share

That is why you get an error. According to iOS 6.0, the Documentation Set UITableView Reference Reference indicates that dequeueReusableCellWithIdentifier: is available in iOS 2.0 and later, and dequeueReusableCellWithIdentifier:forIndexPath: is available in iOS 6.0 and later.

+7
Nov 22
source share



All Articles