Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.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
Iphone iOS多行EasyTableView_Iphone_Ios_Ipad_Uitableview - Fatal编程技术网

Iphone iOS多行EasyTableView

Iphone iOS多行EasyTableView,iphone,ios,ipad,uitableview,Iphone,Ios,Ipad,Uitableview,我正在使用创建带有图像的可滚动表格视图。它的工作原理与演示中给出的一样好 但我的自定义要求是有2行而不是1行。因此,我决定为表中的单个单元格添加2个图像视图,而不是1个 - (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rect { // Create a container view for an EasyTableView cell UIView *container =

我正在使用创建带有图像的可滚动表格视图。它的工作原理与演示中给出的一样好

但我的自定义要求是有2行而不是1行。因此,我决定为表中的单个单元格添加2个图像视图,而不是1个

- (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rect {
    // Create a container view for an EasyTableView cell
    UIView *container = [[UIView alloc] initWithFrame:rect];;

    // Setup an image view to display an image
    UIImageView *imageView  = [[UIImageView alloc] initWithFrame:CGRectMake(1, 0, rect.size.width-2, rect.size.height/2)];
    imageView.tag           = IMAGE_TAG;
    imageView.contentMode   = UIViewContentModeScaleAspectFill;

    [container addSubview:imageView];

    // Setup a label to display the image title
    CGRect labelRect        = CGRectMake(10, rect.size.height/2-20, rect.size.width-20, 20);
    UILabel *label          = [[UILabel alloc] initWithFrame:labelRect];
    label.textAlignment     = UITextAlignmentCenter;
    label.textColor         = [UIColor colorWithWhite:1.0 alpha:0.5];
    label.backgroundColor   = [UIColor clearColor];
    label.font              = [UIFont boldSystemFontOfSize:14];
    label.tag               = LABEL_TAG;

    [container addSubview:label];

    // Setup an image view to display an image
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(1, rect.size.height/2, rect.size.width-2, rect.size.height)];
    imageView.tag           = IMAGE_TAG2;
    imageView.contentMode   = UIViewContentModeScaleAspectFill;

    [container addSubview:imageView2];

    // Setup a label to display the image title
    CGRect labelRect2       = CGRectMake(10, rect.size.height-20, rect.size.width-20, 20);
    UILabel *label2         = [[UILabel alloc] initWithFrame:labelRect2];
    label.textAlignment     = UITextAlignmentCenter;
    label.textColor         = [UIColor colorWithWhite:1.0 alpha:0.5];
    label.backgroundColor   = [UIColor clearColor];
    label.font              = [UIFont boldSystemFontOfSize:14];
    label.tag               = LABEL_TAG2;

    [container addSubview:label2];

    return container;
}

// Second delegate populates the views with data from a data source

- (void)easyTableView:(EasyTableView *)easyTableView setDataForView:(UIView *)view forIndexPath:(NSIndexPath *)indexPath {
    // Set the image title for the given index
    UILabel *label = (UILabel *)[view viewWithTag:LABEL_TAG];
    label.text = [self.imageStore.titles objectAtIndex:indexPath.row];

    // Set the image for the given index
    UIImageView *imageView = (UIImageView *)[view viewWithTag:IMAGE_TAG];
    imageView.image = [self.imageStore imageAtIndex:indexPath.row];

    // Set the image title for the given index
    UILabel *label2 = (UILabel *)[view viewWithTag:LABEL_TAG2];
    label2.text = [self.imageStore.titles objectAtIndex:indexPath.row];

    // Set the image for the given index
    UIImageView *imageView2 = (UIImageView *)[view viewWithTag:IMAGE_TAG2];
    imageView2.image = [self.imageStore imageAtIndex:indexPath.row];

}
最初测试时,我对两个单元格使用相同的图像和标签。但令人怀疑的是,它显示的图像和第一行上的行意味着任何细胞的第一个图像


我怎样才能达到我的要求。

在中使用一些数学来解决它,在
-(void)image:(UIImage*)image loadedAtIndex:(nsInteger)index{
中使用一些数学来解决它。但我会期待任何其他好的解决方案。