Home > Objective-C, iPhone Development > UITableViewCell cannot be loaded from Nib file

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

#import

/**
* 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

@implementation UITableViewCellContentView

+ (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.

  • Add to favorites
  • Digg
  • del.icio.us
  • DZone
  • Reddit
  • StumbleUpon
  • Slashdot
  • Tumblr
  • Twitter
  • FriendFeed
  • Facebook
  • Google Bookmarks
  • MySpace
  • Faves
  1. March 6th, 2010 at 04:15 | #1

    Thanks 1000000000 times ! I was looking for an issue since 3 hours…

  2. March 6th, 2010 at 12:21 | #2

    @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.

  1. No trackbacks yet.
Did you know that it is also possible to register as a user? this enables you to create comments without constantly specifying your name, e-mail and captcha code. Register