Вопрос

Так что у меня был следующий код:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *CellIdentifier = @"FriendsCell";

    FriendData * fd = [self.friendsDataSource_ objectAtIndex:indexPath.row];

    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    [cell.imageView  setImageWithURL:[NSURL URLWithString:fd.imageUrl_]];
    [cell.imageView setFrame:CGRectMake(0, 0, 30, 30)];
    [cell.textLabel setText:fd.name_];

    return cell;
}
.

Однако я не вижу ImageView в ячейке.Что я делаю не так?

Это было полезно?

Решение

1) Установите изображение с URL - это не метод iOS.Это что-то обычай, и это может быть проблема.Но пока вы не опублилируете, это не может помочь там.

2) Я думаю, что Cell.ImageView будет игнорировать "setframe".Я не могу получить это для работы в любом из моих клеток в таблице, используя изображение.Это всегда кажется по умолчанию ширина изображения.

3) Обычно вы устанавливаете изображение с помощью Cell.imageView.image= your_image.ImageView является готовностью и, вероятно, рамка ImageView является частной.

4) Я думаю, что вам нужно будет создать собственную собственную ячейку.

Другие советы

Я получил такую же проблему с sdimagecache.Мое решение состоит в том, чтобы поставить изображение для заполнения с размером рамы, который вы хотите.

 UIImage *placeholder = [UIImage imageNamed:@"some_image.png"];
 [cell.imageView setImage:placeholder];
 [cell.imageView setImageWithURL:[NSURL URLWithString:fd.imageUrl_]];
.

Использование метода с заполнителем исправит его.

[cell.imageView setImageWithURL:[NSURL URLWithString:fd.imageUrl_]placeholderImage:[UIImage imageNamed:@"placeholder"]];
.

Вам нужно return cell в конце метода

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *CellIdentifier = @"FriendsCell";

    FriendData * fd = [self.friendsDataSource_ objectAtIndex:indexPath.row];

    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    [cell.imageView  setImageWithURL:[NSURL URLWithString:fd.imageUrl_]];
    [cell.imageView setFrame:CGRectMake(0, 0, 30, 30)];
    [cell.textLabel setText:fd.name_];
    return cell;
}
.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top