我的代码

时间:2016-08-19 06:19:42

标签: ios objective-c uiscrollview

只有最后一张图片显示原因?在Log中,Image的数组列表正在显示

-(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];
}

2 个答案:

答案 0 :(得分:0)

尝试这样的事情;

-(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];

}

答案 1 :(得分:-1)

-(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* images = [[UIImageView alloc] init];
    [images sd_setImageWithURL:[NSURL URLWithString:[bannerimages_list objectAtIndex:i]]placeholderImage:[UIImage imageNamed:@"placeholderm.png"]];
    images.frame = CGRectMake(i * self.view.frame.size.width, 0, self.view.frame.size.width, 320);
    [self.baner_scrool addSubview:images];

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

}

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

}