0
votes

I am trying to load images from array to my iCarousel view. But images are not displaying.. I have done this code :=

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view {
    UILabel *label = nil;
    UIImageView *eventImg = nil;
    const NSInteger LblTag = 1;
    const NSInteger ImgTag = 2;

    NSLog(@"THIS INDEX %ld",(long)index);
    NSLog(@"Flyer AT thisss INDEX=====%@",[[arrAllEvents objectAtIndex:index] valueForKey:@"flyer_image"]);

    if (view == nil) {

        eventImg = [[UIImageView alloc] initWithFrame:CGRectMake(_barEventsListView.frame.origin.x, _barEventsListView.frame.origin.y, _barEventsListView.frame.size.width - 70, _barEventsListView.frame.size.height - 40)];

        eventImg.tag = ImgTag;
        view.contentMode = UIViewContentModeScaleToFill;

        label = [[UILabel alloc] initWithFrame:view.bounds];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [label.font fontWithSize:50];
        label.tag = LblTag;

        [view addSubview:label];
        [view addSubview:eventImg];

    }
    else {
        label = (UILabel *)[view viewWithTag:1];
        eventImg = (UIImageView *)[view viewWithTag:2];

    }

    [eventImg sd_setImageWithURL:[NSURL URLWithString:[[arrAllEvents valueForKey:@"flyer_image"] objectAtIndex:index]] placeholderImage:[UIImage imageNamed:@"user_upload"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

    }];
    return view;
}

Can anyone help what i am doing wrong here

1
The problem with the View which your are return in this methods. You need to alloc that in its nil.Sumeet Mourya
@Mady thanks for your answer !!Niharika

1 Answers

0
votes

Your else block needs view creation logic; view = view.new