I've created a nib for a custom UITableView cell and followed the documentation and different tutorials to get past this error and it just won't let up. I researched this error and people say it's when you #import a header but you didn't add the Framework. Well, UIKit is automatically added, and I removed and added it again for good measure and this error won't let up. Here is my code for - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *MyIdentifier = @"PersonCell";
PersonCell *c开发者_StackOverflow中文版ell = (PersonCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"PersonCell" owner:self options:nil];
cell = personCell;
}
return cell;
Found solution in dev forums
Create this files:
UITableViewCellContentView.h
#import <UIKit/UIKit.h>
@interface UITableViewCellContentView : UIView {
}
UITableViewCellContentView.m
@implementation UITableViewCellContentView
+ (id)alloc {
return [UIView alloc];
}
+ (id)allocWithZone:(NSZone *)zone {
return [UIView allocWithZone:zone];
}
@end
Oddly enough, I had an app working in 3.1.2 for months and just downloaded the new 3.2 SDK for iPad, and my app ran fine in 3.2. However, when I created my target in 3.1.2 (within the 3.2 SDK) and all the sudden had a null pointer in class UITableViewCellContentView (which I have never seen before). I am a novice at Obj C and could not figure out what what happening. Found your entry by googling my error. I just reloaded the Original 3.1.2 SDK and the problem went away. Hope this helps. Not sure if my code has a hidden error that is being triggered by the new SDK or there is something deeper going on. I suspect it's my code, but it looks identical to your code in creating a custom cell for a table view.
Had the same problem: after installing 3.2 beta, compiling to the 3.1.2 yielded this.
Adding the UITableViewCellContentView' class worked for me in the simulator but I get an error on the phone when I run it.
*** NSInvocation: warning: object 0x51b9c of class 'UITableViewCellContentView' does not implement doesNotRecognizeSelector: -- abort
I guess I'll have to reinstall the previous xcode.
I started getting the same error when running in 3.1.2 after installing the SDK 3.2 beta. If I run my app in 3.2 (on the iPad simulator) it works fine.
精彩评论