sai sai - 3 months ago 8
Objective-C Question

Is any thing wrong in my code

Only last image is displaying why? in Log my array list of

Image
are displaying

-(void)BanerSlideshow{

baner_scrool.delegate = self;
baner_scrool.scrollEnabled = YES;
baner_scrool.backgroundColor=[UIColor clearColor];

NSLog(@"howmany %lu",(unsigned long)[bannerimages_list count]);


for (int i = 0; i < [bannerimages_list count]; i++)
{
[baner_image sd_setImageWithURL:[NSURL URLWithString:[bannerimages_list objectAtIndex:i]]placeholderImage:[UIImage imageNamed:@"placeholderm.png"]];

NSLog(@"rrr value %@", [bannerimages_list objectAtIndex:i]);

}

[baner_scrool setContentSize:CGSizeMake(320 * [bannerimages_list count], baner_scrool.frame.size.height)];
[baner_scrool setShowsHorizontalScrollIndicator:NO];
[self.baner_scrool addSubview:baner_image];
}

Answer

Try something like this;

-(void)BanerSlideshow{
    baner_scrool.delegate = self;
    baner_scrool.scrollEnabled = YES;
    baner_scrool.backgroundColor=[UIColor clearColor];


NSLog(@"howmany %lu",(unsigned long)[bannerimages_list count]);


for (int i = 0; i < [bannerimages_list count]; i++)
{
    UIImageView* baner_imageV2 = [[UIImageView alloc] init];
    [baner_imageV2 sd_setImageWithURL:[NSURL URLWithString:[bannerimages_list objectAtIndex:i]]placeholderImage:[UIImage imageNamed:@"placeholderm.png"]];
    baner_imageV2.frame = CGRectMake(i * 320, 0, 320, 320);
    [self.baner_scrool addSubview:baner_imageV2];

    NSLog(@"rrr value %@", [bannerimages_list objectAtIndex:i]);

}

[baner_scrool setContentSize:CGSizeMake(320 * [bannerimages_list count], baner_scrool.frame.size.height)];
[baner_scrool setShowsHorizontalScrollIndicator:NO];

}