我想在UIImageView
下添加各種UIImages
並允許它們使用UIScrollView
滾動。我不確定如何在UIImageView
下添加各種圖像並讓它們滾動。 以下是我的代碼,它在UIImageView
上添加圖像並使其可滾動。在UIScrollView中添加10個不同的UIImages
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *image = [UIImage imageNamed:@"ae.jpg"];
imageView = [[UIImageView alloc]initWithImage:image];
imageView.frame = [[UIScreen mainScreen] bounds];
imageView.contentMode = (UIViewContentModeScaleAspectFit);
imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
imageView.backgroundColor = [UIColor clearColor];
UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
scrollView.contentMode = (UIViewContentModeScaleAspectFit);
scrollView.contentSize = CGSizeMake(image.size.width,960);
scrollView.pagingEnabled = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.alwaysBounceVertical = NO;
scrollView.alwaysBounceHorizontal = NO;
scrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
scrollView.maximumZoomScale = 2.5;
scrollView.minimumZoomScale = 1;
scrollView.clipsToBounds = YES;
[scrollView addSubview:imageView];
[image release];
[imageView release];
[self.view addSubview:scrollView];
}
您可能想在同一個UIScrollView中使用多個UIImageViews。但目前還不清楚你想要做什麼。 – jtbandes
我想將各種圖像添加到另一個下方,例如想要在「ae.png」下添加另一個圖像並允許它滾動。可以說目前它只有一個圖像,但是如果我想在UIIImageView中添加一個圖像數組,可以嗎? – lifemoveson
只需使用多個UIImageView。 – jtbandes