IOS新手正在学习IOS,发现一个问题
for(int i=0;i<totalCount;i++){
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*bannerBounds.size.width, bannerBounds.origin.y, bannerBounds.size.width, bannerBounds.size.height)];
imageView.frame = bannerBounds;
imageView.image = [UIImage imageNamed:@”banner”];
[ _bannerImageArray addObject:imageView ]; //@property(nonatomic,strong) NSMutableArray *bannerImageArray;
}
为什么_bannerImageArray在这个里面获取的UImageView不能给每一个UImageView设置banner这张图片?
for(int i=0;i<totalCount;i++){
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*bannerBounds.size.width, bannerBounds.origin.y, bannerBounds.size.width, bannerBounds.size.height)];
imageView.frame = bannerBounds;
imageView.image = [UIImage imageNamed:@”banner”];
[ _bannerImageArray addObject:imageView ]; //@property(nonatomic,strong) NSMutableArray *bannerImageArray;
}
为什么_bannerImageArray在这个里面获取的UImageView不能给每一个UImageView设置banner这张图片?
解决方案
20
1.检查一下bannerImageArray有没有alloc init
2.检查一下imageView.frame会不会正确
3. imageView没有添加到任何view上,只是创建了而已
2.检查一下imageView.frame会不会正确
3. imageView没有添加到任何view上,只是创建了而已