내 앱에서 한 번에 5 개의 이미지를 선택하고 작은보기로 표시하고 버튼을 클릭하면 해당보기의 5 개 이미지가 다음 View Controller로 이동해야하지만 버튼을 클릭 할 때 0 번째 인덱스의 이미지 만 지나가고 나머지 이미지는 지나치지 않습니다. 누군가가 나를 도와 줄 수 있습니다.한 번에 여러 이미지를 다른보기로 전달하는 방법?
그리고 여기 내 코드입니다.이 코드는 첫 번째 뷰에서 두 번째 뷰로 넘어가고 selectedImages는 모든 선택된 이미지
SecondViewController *secview=[[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
if (secview.imgView.tag==0) {
secview.img=[self.chosenImages objectAtIndex:0];
}
else if (secview.imgView1.tag==1)
{
secview.img=[self.chosenImages objectAtIndex:1];
}
else if (secview.imgView1.tag==2)
{
secview.img=[self.chosenImages objectAtIndex:2];
}
else if (secview.imgView1.tag==3)
{
secview.img=[self.chosenImages objectAtIndex:3];
}
else if (secview.imgView1.tag==4)
{
secview.img=[self.chosenImages objectAtIndex:4];
}
NSLog(@"%@",secview.img);
[self presentViewController:secview animated:YES completion:nil];
을 절약하고 두번째보기에 내 코드는 다음과 같습니다
,210업데이트 : didFinishPickingMedia에서이 코드
images = [NSMutableArray arrayWithCapacity:[info count]];
for (NSDictionary *dict in info) {
if ([dict objectForKey:UIImagePickerControllerMediaType] == ALAssetTypePhoto){
if ([dict objectForKey:UIImagePickerControllerOriginalImage]){
image=[dict objectForKey:UIImagePickerControllerOriginalImage];
[images addObject:image];
UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
}
}
else {
NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
}
}
self.chosenImages = images;
[AllImages setHidden:NO];
previousButtonTag=1000;
scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 4, self.AllImages.frame.size.width, 104)];
int x =0.5;
for (int i=0; i<5; i++) {
button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(x, 0, 100, 123);
button.layer.borderWidth=0.5;
button.titleLabel.font=[UIFont boldSystemFontOfSize:12];
button.titleLabel.textAlignment = NSTextAlignmentCenter;
button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
// button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
button.tag = i;
[button setBackgroundImage:[self.chosenImages objectAtIndex:i] forState:UIControlStateNormal];
[button addTarget:self action:@selector(OverLayMethod:) forControlEvents:UIControlEventTouchUpInside];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[scrollView addSubview:button];
x += button.frame.size.width;
x=x+6.0;
}
scrollView.contentSize = CGSizeMake(x, scrollView.frame.size.height);
scrollView.backgroundColor = [UIColor clearColor];
[self.AllImages addSubview:scrollView];
}
이 destinationview에 하나 개 더있는 UIImage 객체를 생성하고 그 객체와 이미지를 전달 올바른 출력을 얻고있다. –
답장을 보내 주셔서 감사합니다. @Darshan Kunjadiya .. img는 두 번째보기 자체의 객체입니다. –