Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在滚动视图中显示初始子视图的选定缩略图_Ios_Indexing_Scrollview_Collectionview - Fatal编程技术网

Ios 在滚动视图中显示初始子视图的选定缩略图

Ios 在滚动视图中显示初始子视图的选定缩略图,ios,indexing,scrollview,collectionview,Ios,Indexing,Scrollview,Collectionview,试图从集合视图中的图像数组中获取所选图像,使其成为滚动视图中的初始子视图。现在,无论在集合视图中点击哪个图像,scrollView都会从阵列加载第一个图像。请提供一些关于如何实现这一目标的建议或网站信息。谢谢 for (int i = 0; i < self.album.count; i++) { CGRect frame; frame.origin.x = self.scrollView.frame.size.width * i; frame.origin.y

试图从集合视图中的图像数组中获取所选图像,使其成为滚动视图中的初始子视图。现在,无论在集合视图中点击哪个图像,scrollView都会从阵列加载第一个图像。请提供一些关于如何实现这一目标的建议或网站信息。谢谢

 for (int i = 0; i < self.album.count; i++) {
    CGRect frame;
    frame.origin.x = self.scrollView.frame.size.width * i;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;

    UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
    subview.image = [self.album objectAtIndex:i];

    [self.scrollView addSubview:subview];
}

self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * self.album.count, self.scrollView.frame.size.height);
}
for(int i=0;i
在创建scrollview时,在下面的行中添加

self.scrollView.contentOffset = CGPointMake(self.scrollView.frame.size.width * self.selectedImage, self.scrollView.frame.size.height);
其中
self.selectedImage
是数组中图像的索引

对不起我的英语