【发布时间】:2013-04-20 18:55:38
【问题描述】:
我的UIScrollView 中有一些图像,我希望如果我点击它们,就会有一个UIScrollView,我可以在其中滚动浏览我的所有图像(就像在照片的应用程序中一样)。我得到了这个代码:
CollectionViewController:
- (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);
如何连接这两者?
【问题讨论】:
-
你是什么意思,“我怎样才能把两者联系起来”?你看到了什么,你想要什么? segue 没有把你带到 ScrollViewController 吗?
-
我不知道collectionviewcontroller 中的图像如何出现在我的scrollviewcontroller 中
标签: ios objective-c uiscrollview uicollectionview