0
콜렉션 뷰에서 상세 뷰 컨트롤러로 데이터를 전달하는 방법을 알아내는 데 도움이 필요합니다. 나는 단순히 이미지를 지나가는 것으로 시작하고있다. 내 코드는 다음과 같습니다 :콜렉션 뷰에서 상세 뷰로 데이터 전달
의 ViewController :
-(MyCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath];
PFObject *imageObject = [imageFilesArray objectAtIndex:indexPath.row];
__block UIImage *MyPicture = [[UIImage alloc]init];
PFFile *imageFile = [imageObject objectForKey:@"test"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
MyPicture = [UIImage imageWithData:data];
cell.CollectionImg.image = [UIImage imageWithData:data];
cell.cellLabel.text = [object objectForKey:@"phone"];
}
}];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
TopDetailViewController *detailVC = [[TopDetailViewController alloc] initWithNibName:@"TopDetailViewController" bundle:[NSBundle mainBundle]];
detailVC.img= [imageFilesArray objectAtIndex: indexPath.row];
[self.navigationController pushViewController:detailVC animated:YES];
}
그리고 자세히보기 :
.H
@property (nonatomic, strong) IBOutlet UIImageView *imageView;
@property (nonatomic, strong) IBOutlet NSString *img;
하는 .m
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageView.image = [UIImage imageNamed:self.img];
// Do any additional setup after loading the view from its nib.
}
누군가가 나를 도울 수 있다면 나가 크게 감사 할 것 인 밖으로 이자형.
그럼 어떻게 써야할까요? 새로운 Detail View Controller에서 개체를 호출 할 수 없습니다. 내가 Xcode에 대해 상당히 새로운 도움을 주셔서 감사합니다. – user3255746
DetailViewController에 "NSString * img"ivar가 있습니까? "UIImage * actualImage"인 다른 이미지를 만들고 같은 방법으로 전달하십시오. –