0

さて、私はカスタムセルを持っています。これが私のコードです:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier=@"ListTableCell";
    //this is the identifier of the custom cell
    ListsCell *cell = (ListsCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ListsCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }

    NSURL *url_left=[NSURL URLWithString:[images_url objectAtIndex:(indexPath.row*2)]];
    cell.Left.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:url_left]];
    NSURL *url_right=[NSURL URLWithString:[images_url objectAtIndex:(indexPath.row*2+1)]];
    cell.Right.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:url_right]];


    return cell;
}

URL は NSLog に出力して問題ないので問題ありません。また、私が見ることができるプロパティから静止画像を配置すると、ウェブからの画像を見ることができます。

配列 image_url は、何も関係がない場合、json 配列を解析してその URL を取得します。

私の中にも

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
... images_url filling with data.
    [self.myTable.reloadData];
}

データをリロードします。

何故ですか?

これらの方法もあります:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int i=[images_url count]/2;
    return i;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 81;
}

[画像数]/2 で時間を無駄にしないでください。これは、10 個の URL があるためですが、カスタム セルにはセルごとに 2 つのイメージビューがあるため、5 行が必要です。

4

0 に答える 0