2014-12-18 18 views
4

у меня есть метод делегата, который извлекает содержимое каждой ячейки, как это:содержание UITableViewCell не показывает

методы
-(void)getRetrievedShopContentStickerName:(NSArray *)stickerNameArray price:(NSArray *)stickerPriceArray profileBackgroundImage:(NSArray *)stickerProfileBackgroundImageArray profile:(NSArray *)stickerProfileImageArray profileMenuImage:(NSArray *)stickerProfileMenuImageArray designerName:(NSArray *)designerNameArray 
{ 
    self.stickerPriceArray = [[NSMutableArray alloc] initWithArray:stickerPriceArray]; 
    self.stickerProfileBGImageArray = [[NSMutableArray alloc] initWithArray:stickerProfileBackgroundImageArray]; 

    NSLog(@"sticker price: %@", self.stickerPriceArray); 
    NSLog(@"sticker bg: %@", self.stickerProfileBGImageArray); 

    [self.shopTableView reloadData]; 
} 

Этот делегат выходит из рабочего массива, как ожидалось. Это код, который я использовал для отображения содержимого просмотра таблицы:

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

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

    if (cell == nil) 
    { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 

     AsyncImageView *backgroundImage = [[AsyncImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)]; //does cell frame get before this method? 
     [backgroundImage setTag:123]; 
     [cell.contentView addSubview:backgroundImage]; 

     UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 250, 250)]; 
     [priceLabel setTag:124]; 
     [priceLabel setFont:[UIFont fontWithName:@"Helvetica-Light" size:30.0f]]; 
     [priceLabel setTextColor:[UIColor blackColor]]; 
     [cell.contentView addSubview:priceLabel]; 
    } 

    [(AsyncImageView *)[cell.contentView viewWithTag:123] loadImageWithTypeFromURL:[NSURL URLWithString:[self.stickerProfileBGImageArray objectAtIndex:indexPath.row]] contentMode:UIViewContentModeScaleAspectFit imageNameBG:nil]; 
    [(UILabel *)[cell.contentView viewWithTag:124] setText:[self.stickerPriceArray objectAtIndex:indexPath.row]]; 

    return cell; 
} 

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return 100; 
} 

Единственное изменение, которое я получить после перезагрузки вид таблицы в методе делегата высота каждого tableviewcell. Почему мое содержание не отображается? Что я сделал не так?

Заранее спасибо

+1

Как насчет источника данных и делегата таблицыView? Связано ли это с viewController? – ingaham

+0

@ingaham да это. перерыв точка работает .... – imstillalive

+0

наклейкаPriceArray является сильным свойством (я полагаю, да, но, чтобы быть уверенным)? – ingaham

ответ

0

я случайно установить идентификатор моей ячейки в раскадровке так if (cell == nil) никогда не называли.

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