Why Can't I import a UITableViewCell subclass ? That's weird
It's like this, I created a UITableViewCell subclass called NewsItemCell, then I wanna use it in my FirstViewController.m, then I tried to import it, but the compiler keeps telling me this
Below is my code, it is driving me mad, thank you if you can help.
#import "NewsItemCell.h"
#import "FirstViewController.h"
@implementation FirstViewController
@synthesize computers;
- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"NewsItemCellIdentifier";
    NewsItemcell *cell = (NewsItemcell *)[tableView 
                                      dequeueReusableCellWithIdentifier: CellIdentifier];
    开发者_如何学Goif (cell == nil)  
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NewsItemCell" 
                                                     owner:self options:nil];
        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[NewsItemcell class]])
                cell = (NewsItemcell *)oneObject;
    }
    NSUInteger row = [indexPath row];
    NSDictionary *rowData = [self.computers objectAtIndex:row];
    cell.newsTitle.text = [rowData objectForKey:@"Color"];
    cell.newsDate.text = [rowData objectForKey:@"Name"];
    return cell;
}
Jason
Should this code
if (cell == nil)  
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NewsItemCell" 
                                                 owner:self options:nil];
    for (id oneObject in nib)
        if ([oneObject isKindOfClass:[NewsItemcell class]])
            cell = (NewsItemcell *)oneObject;
}
not be
if (cell == nil)  
{
    [[NSBundle mainBundle] loadNibNamed:@"NewsItemCell" 
                                                 owner:self options:nil];
    cell = newsItemCellView
}
and NewsItemcell *cell be NewsItemcell *newsItemCellView, as cell may confuse the compiler.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论