サムネイルをクリックすると、スクロールビューの特定の画像に画像を表示したい。サムネイルの選択に従って、画像を表示したい。ScrollView を使用しているだけですが、どうすれば解決できますか? コレクションビューの私のコードは、
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=@"Cell";
customcell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
[[cell nyimage]setImage:[UIImage imageNamed:[temparr objectAtIndex:indexPath.section * 1 + indexPath.row]]];
return cell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"])
{
NSIndexPath *selectedIndexPath = [[self.gallerycollection indexPathsForSelectedItems] objectAtIndex:0];
NSString *imageNameToLoad = [NSString stringWithFormat:@"%d", selectedIndexPath.row];
NSString *pathToImage = [[NSBundle mainBundle] pathForResource:imageNameToLoad ofType:@"jpg"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:pathToImage];
GalleryImageScrollViewController *gallerydetailViewController = [segue destinationViewController];
gallerydetailViewController.FullScreenImageScroller=image;
}
}
スクロールビューは、
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *mutablearray = [NSMutableArray array];
data=[MyDatabase new];
slideImages=[data OpenMyDatabase:@"SELECT pic_name_big FROM interior":@"pic_name_big"];
[mutablearray addObjectsFromArray:slideImages];
temparr = [[NSMutableArray alloc]init];
temparr=[NSMutableArray arrayWithArray:mutablearray];
[self putImageViewsInScrollView:[temparr count]];
self.FullScreenImageScroller.delegate=self;
}
-(void) putImageViewsInScrollView:(int)numberOfImageViews
{
for(int i=0 ;i<numberOfImageViews; i++)
{
fullScreenImageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:[temparr objectAtIndex:i]]];
fullScreenImageView.frame = CGRectMake((WIDTH_OF_IMAGE * i) , 0, WIDTH_OF_IMAGE, HEIGHT_OF_IMAGE);
[self.FullScreenImageScroller addSubview:fullScreenImageView];
}
[self.FullScreenImageScroller setContentSize:CGSizeMake(WIDTH_OF_SCROLL_PAGE * ([temparr count]), HEIGHT_OF_IMAGE)];
[self.FullScreenImageScroller setContentOffset:CGPointMake(0, 0)];
[self.FullScreenImageScroller scrollRectToVisible:CGRectMake(WIDTH_OF_IMAGE,0,WIDTH_OF_IMAGE,HEIGHT_OF_IMAGE) animated:NO];
}