Domanda

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

È stato utile?

Soluzione 2

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.

Altri suggerimenti

1. dequeueReusableHeaderFooterViewWithIdentifier
Availability
Available in iOS 2.0 and later.
-> Minimum iOS version required to run this function is iOS 2.0

2 .dequeueReusableCellWithIdentifier:forIndexPath:
Availability
Available in iOS 6.0 and later.
-> Minimum iOS version required to run this function is iOS 6.0

EDIT IF your want to use this function the you can check your current device version and then implement this

NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
NSLog(@"curr version = %f",[currSysVer floatValue]);

if ([currSysVer floatValue] >= 6) {
    //iOS 6.0 and later code
    // dequeueReusableCellWithIdentifier:forIndexPath:
}
else{
    //dequeueReusableHeaderFooterViewWithIdentifier
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top