Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在一个单元格中放置3个图像_Objective C_Ios_Cocoa Touch_Uitableview - Fatal编程技术网

Objective c 如何在一个单元格中放置3个图像

Objective c 如何在一个单元格中放置3个图像,objective-c,ios,cocoa-touch,uitableview,Objective C,Ios,Cocoa Touch,Uitableview,我已经在我的示例项目中实现了。我想在我的1个单元格中显示3个图像,你能告诉我怎么做吗?这是我的示例代码,如下所示。我可以尝试这样做,但它没有在1个单元格中显示3个图像。我可以制作算法,该算法在其他项目中运行良好,但LazyTableImage不起作用吗?请告诉我怎么做 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { stati

我已经在我的示例项目中实现了。我想在我的1个单元格中显示3个图像,你能告诉我怎么做吗?这是我的示例代码,如下所示。我可以尝试这样做,但它没有在1个单元格中显示3个图像。我可以制作算法,该算法在其他项目中运行良好,但LazyTableImage不起作用吗?请告诉我怎么做

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    static NSString *PlaceholderCellIdentifier = @"PlaceholderCell";

    int nodeCount = [self.currentSelectedCategoryArray count]/4;

    if (nodeCount == 0 && indexPath.row == 0)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                           reuseIdentifier:PlaceholderCellIdentifier] autorelease];   
            cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }

        cell.detailTextLabel.text = @"Loading…";

        return cell;
    }

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

    int check = indexPath.row;
    check = check*3;

        for (int i = 0; i < 3; i++){

            if(check+i < [self.currentSelectedCategoryArray count]){

                if (nodeCount > 0)
                {
                    // Set up the cell...
                    imageClass *imgC = [self.currentSelectedCategoryArray objectAtIndex:check+i];

                    cell.textLabel.text = imgC.imageName;
                    cell.detailTextLabel.text = imgC.imageID;

                    // Only load cached images; defer new downloads until scrolling ends
                    if (!imgC.cImage)
                    {
                        if (tableView.dragging == NO && tableView.decelerating == NO)
                        {
                            [self startImageDownload:imgC forIndexPath:indexPath];
                        }
                        // if a download is deferred or in progress, return a placeholder image
                        cell.imageView.image = [UIImage imageNamed:@"imageFrame.png"];                
                    }
                    else
                    {
                        cell.imageView.image = imgC.cImage;
                    }

                }

            }

        }
return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*CellIdentifier=@“Cell”;
静态NSString*占位符单元格标识符=@“占位符单元格”;
int nodeCount=[self.currentSelectedCategoryArray count]/4;
if(nodeCount==0&&indexath.row==0)
{
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:Placeholder CellIdentifier];
如果(单元格==nil)
{
单元格=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:占位符CellIdentifier]自动释放];
cell.detailTextLabel.textAlignment=UITextAlignmentCenter;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
cell.detailTextLabel.text=@“正在加载…”;
返回单元;
}
UITableViewCell*单元格=[self.detailCatTable dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil)
{
单元格=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier]自动释放];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
int check=indexPath.row;
检查=检查*3;
对于(int i=0;i<3;i++){
如果(检查+i<[self.currentSelectedCategoryArray计数]){
如果(节点计数>0)
{
//设置单元格。。。
imageClass*imgC=[self.currentSelectedCategoryArray对象索引:检查+i];
cell.textlab.text=imgC.imageName;
cell.detailtextlab.text=imgC.imageID;
//仅加载缓存的图像;推迟新的下载,直到滚动结束
如果(!imgC.cImage)
{
if(tableView.dragging==NO&&tableView.declaring==NO)
{
[self-startImageDownload:imgC-forindepath:indepath];
}
//如果下载延迟或正在进行,请返回占位符图像
cell.imageView.image=[UIImage ImageName:@“imageFrame.png”];
}
其他的
{
cell.imageView.image=imgC.cImage;
}
}
}
}
返回单元;
}

我会在自己的nib中设计一个定制的
UITableViewCell
;这样您就可以直观地布局三个
UIImageView
实例


然后,您将从nib直接或通过
UINib
实例化单元,而不是
[[UITableViewCell alloc]init…]
从nib加载单元,
单元中只有1个
图像视图
。您应该按照@alan duncan的建议创建自定义
UITableViewCell

在您的代码中,可以有如下内容:

switch(i){
     case 0:
      ((UIImageView*)[cell.contentView viewWithTag:1]).image = imgC.cImage;
     break;

     case 1:
      ((UIImageView*)[cell.contentView viewWithTag:2]).image = imgC.cImage;
     break;

     case 2:
      ((UIImageView*)[cell.contentView viewWithTag:3]).image = imgC.cImage;
     break;
}
我希望你能明白