我制作了一个 UIScrollView 并显示来自 Array 的图像,但图像未显示
这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
imageScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(13.0, 50.0, 292.0, 69.0)];
[self makeScroll];
}
-(void)makeScroll
{
imageScroll.delegate = self;
imageScroll.backgroundColor = [UIColor clearColor];
int arrayCount = [myArray count];
imageScroll.contentSize = CGSizeMake(arrayCount * 101.0, 69.0);
for (int i = 0; i < arrayCount; i++)
{
participantView = [[UIView alloc]init];
if (i == 0) {
participantView.frame = CGRectMake(0.0, 2.0, 91.0, 67.0);
}
else {
participantView.frame = CGRectMake(101.0*i, 2.0, 91.0, 67.0);
}
participantView.backgroundColor = [UIColor yellowColor];
//declaring the view in which image object will be added
UIImageView *bannerImage = [[UIImageView alloc]
initWithFrame:CGRectMake(0.0,0.0,91.0,67.0)];
//taking out the image object
UIImage *imageNamed = [UIImage imageNamed:[myArray objectAtIndex:0]];
//resizing the image
// UIImage *imageNamed2 = [imageNamed
imageByScalingAndCroppingForSize:CGSizeMake(91.0,67.0)];
//setting the resized image in UIImageView
[bannerImage setImage:imageNamed];
//clear the bg
bannerImage.backgroundColor = [UIColor clearColor];
bannerImage.autoresizingMask = UIViewAutoresizingFlexibleHeight;
bannerImage.contentMode = UIViewContentModeScaleAspectFit;
[bannerImage setNeedsLayout];
bannerImage.frame = CGRectMake(0.0,0.0,91.0,67.0);
[participantView addSubview:bannerImage];
[imageScroll addSubview:participantView];
}
[self.view addSubview:imageScroll];
}
谁能告诉我我在哪里做错了
问题是:图像未在滚动视图中显示