2013-11-01 2 views
0

У меня были ячейки таблицы, отображающие данные правильно, но затем создавались пользовательские ячейки и классы, чтобы я мог больше контролировать макет ... но я не могу получить свою пользовательскую ячейку чтобы показать данные ... они просто показывают ярлыки со своим текстом-заполнителем ... что мне не хватает?Пользовательская ячейка UITableView, не отображающая данные ядра

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return self.results.count; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"CellResults"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    // Configure the cell... 

    ResultsCell *resultscell = (ResultsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    NSManagedObject *result = [self.results objectAtIndex:indexPath.row]; 


    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; 
    [dateFormatter setDateFormat:@"MMMM dd, yyyy"]; 
    [dateFormatter setTimeZone:[NSTimeZone localTimeZone]]; 
    NSString *eventDate = [dateFormatter stringFromDate:[self trialDate]]; 

    // formatting 
    resultscell.labelEventDesc.numberOfLines = 0; 

    // populate the cells 
    [resultscell.labelEventDesc setText:[NSString stringWithFormat:@"%@",[result valueForKey:@"eventdesc"]]]; 
    [resultscell.labelWeeksOut setText:[NSString stringWithFormat:@"%@",[result valueForKey:@"weeksout"]]]; 
    [resultscell.labelEventDate setText:[NSString stringWithFormat:@"%@",eventDate]]; 
    return cell; 
} 

ответ

1

Вы создаете 2 разные экземпляры клеток (cell и resultscell), настройку одного и возвращение других. Поэтому ваш пользовательский экземпляр класса никогда не используется ни для чего.

Снимите:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

и изменить return cell; к return resultscell;.

+0

Пятно на! Удивительно, как вы можете смотреть на кусок кода навсегда, и все, что требуется, - это еще один набор глаз, чтобы увидеть что-то очевидное. Большое спасибо ... отлично работает. – Mark

Смежные вопросы