我的 中有一些图像UIScrollView
,如果我点击它们,我希望有一个UIScrollView
可以滚动浏览所有图像的位置(就像在照片的应用程序中一样)。我得到了这个代码:
集合视图控制器:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//ImageDetailSegue
if ([segue.identifier isEqualToString:@"ScrollView"]) {
Cell *cell = (Cell *)sender;
NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];
int imageNumber = indexPath.row % 9;
ScrollViewController *divc = (ScrollViewController *)[segue destinationViewController];
divc.img = [UIImage imageNamed:[NSString stringWithFormat:@"full%d.png", imageNumber]];
}
}
滚动视图控制器:
for (int i = 1; i < 4; i++) {
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"full%d.png", i]]];
image.frame = CGRectMake((i - 1) * 320, 0, 320, 240);
[imageScroller addSubview:image];
}
imageScroller.contentSize = CGSizeMake(320 * 6, 240);
我怎样才能连接这两个?