2010-04-19 100 views
0

是這樣的,我創建了一個UITableViewCell子類,稱爲NewsItemCell,那麼我想在我的FirstViewController.m使用它,然後我試圖將其導入,但是編譯器不斷告訴我這個爲什麼我不能導入UITableViewCell子類?這是奇怪的

下面是我的代碼,它讓我發瘋,謝謝你,如果你能幫忙。

#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]; 
    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; 
    } 
    NSUInteger row = [indexPath row]; 
    NSDictionary *rowData = [self.computers objectAtIndex:row]; 
    cell.newsTitle.text = [rowData objectForKey:@"Color"]; 
    cell.newsDate.text = [rowData objectForKey:@"Name"]; 
    return cell; 
} 

傑森

回答

0

如果這一代碼

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; 
} 

if (cell == nil) 
{ 
    [[NSBundle mainBundle] loadNibNamed:@"NewsItemCell" 
               owner:self options:nil]; 
    cell = newsItemCellView 
} 

NewsItemcell *cellNewsItemcell *newsItemCellView,因爲電池可能會混淆編譯器。

+0

感謝您的幫助,事實上,我錯誤地鍵入了NewsItemcell,它應該是NewsItemCell,無論如何。 – user320064 2010-04-20 11:24:29

+0

沒問題。很高興問題得到解決:) – jrtc27 2010-04-20 16:56:54

相關問題