我需要在視圖中水平滾動2個圖像。我已經很好地實現了單個圖像滾動,但沒有在滾動視圖中顯示多個圖像。我附上了單個滾動的代碼。下面是我需要實現的附加圖片。 UIScrollView具有多個圖像水平
galleryScrollView = [UIScrollView new];
galleryScrollView.pagingEnabled = YES;
galleryScrollView.backgroundColor = [UIColor clearColor];
galleryScrollView.translatesAutoresizingMaskIntoConstraints = NO;
galleryScrollView.showsHorizontalScrollIndicator = NO;
galleryScrollView.showsVerticalScrollIndicator = NO;
galleryScrollView.delegate = self;
galleryScrollView.scrollEnabled = YES;
[backView addSubview:galleryScrollView];
for(int i=0;i<resultDict.count;i++) {
CGRect frame;
frame.origin.x= galleryScrollView.frame.size.width *i;
frame.origin.y=0;
frame.size=galleryScrollView.frame.size;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.translatesAutoresizingMaskIntoConstraints = YES;
imageView.clipsToBounds = YES;
NSString *imageString = [[resultDict valueForKey:@"ImageURL"] objectAtIndex:i];
[imageView setImageWithURL:[NSURL URLWithString:imageString]];
[galleryScrollView addSubview:imageView];
}
galleryScrollView.contentSize=CGSizeMake(galleryScrollView.frame.size.width * resultDict.count, galleryScrollView.frame.size.height);
在屏幕上你想在一次顯示一個圖像? – ilesh
不,我想在一個屏幕上顯示2張圖像 – Kashif
比您需要在圖像之間添加視圖,它可以幫助您滾動圖像 – ilesh