UITableViewCell cannot be loaded from Nib file
Since the announcement of the iPad by Apple there is also a new SDK (3.2 Beta) available when you are a member of the Apple Developer Program. So, curious as i am i started the download the same evening along with the new version of XCode (3.2.2 Snow Leapard). During the installation it suggested to update the current installation of my XCode, since i prever to use one XCode for the various SDK versions i followed that suggestion.
So when that was done i compiled my iPhone application against the iPad SDK to see if it would work in the iPad simulator and it did so that is really nice. The next day i started to continue the development of the application using the latest (at that time 3.1.2) SDK for the iPhone.
One would expect that adding a newer SDK would not interfere with the older SDK’s but to my surprise it did. The application has a number of tables which contain custom UITableViewCell components which are loaded from a Nib file. But running the same application with the same SDK (3.1.2) failed because it crashes when loading the custom UITableViewCell. My first assumption was that i made a mistake somewhere but after some debugging time i started to look around on forums to see if other people encountered this problem. And indeed, i wasn’t the only person who has this problem.
So how to solve this, well, it is a kind of weird solution but apparently the SDK does influence the older SDK and the sollution is as follow, you need to add a new class UITableViewCellContentView, you don’t have to use it as long as it exists within your project:
UITableViewCellContentView.h
/**
* Really strange work-arround for the Beta 3.2 SDK (iPad), it even influences
* the standard SDK 3.1.2
*/
@interface UITableViewCellContentView : UIView {
}
@end
UITableViewCellContentView.m
+ (id)alloc {
return [UIView alloc];
}
+ (id)allocWithZone:(NSZone *)zone {
return [UIView allocWithZone:zone];
}
@end
So that is it, add this to your project and you can load your UITableViewCell custom components from Nib files again.
Thanks 1000000000 times ! I was looking for an issue since 3 hours…
@moute
Indeed, trying out a new beta sdk is nice, but i never expected these kind of problems, i was also looking for a few hours before i found it. Glad my post could help you.