콜렉션 뷰가있는 아이폰 포토 갤러리를 상세보기로 복제하려는 마음이 천천히 떨어지고 있습니다. 세부 사항보기에 사진 갤러리와 마찬가지로 페이징 기능을 달기를 원합니다. 않습니다. 지금까지 코드를로드하는 것 같지만 오류가 있습니다. 면제 중단 점이 있고 중단 점 1.1 충돌 지점은 self.imageView.image = img; 줄입니다. 이것은 (lldb) 이외의 로그에있는 오류에 대해서는 언급하지 않습니다.컬렉션보기에서 상세보기 문제로 연결
제가 잘못 읽은 부분을 지적하고 누군가를 고칠 수 있는지 궁금합니다. . 나는 또한 상세 뷰에 걸쳐 각 이미지에 대한 제목을하고 싶지만 어디에서 이것을 추가하는 방법/몰랐다
내가 가진 코드는 다음과 같습니다
#import "MarbleCollectionViewController.h"
#import "DetailViewController.h"
@interface MarbleCollectionViewController() {
NSArray *marbleImages;
}
@end
@implementation MarbleCollectionViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
marbleImages = [NSArray arrayWithObjects:@"arabescato.jpg",
@"bianco-carrara.jpg",
@"botticino-classico2.jpg",
@"Calacatta_Oro.jpg",
@"crema-marfil-3.jpg",
@"crema-valencia.jpg",
@"emperador-dark.jpg",
@"jura-beige.jpg",
@"nero-marquina.jpg",
@"perlato-olympo.jpg",
@"rojo-alicante_marbleGRP1.jpg", nil];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return marbleImages.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *marbleImageView = (UIImageView *)[cell viewWithTag:100];
marbleImageView.image = [UIImage imageNamed:[marbleImages objectAtIndex:indexPath.row]];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"detailView" sender:collectionView];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"detailView"]) {
DetailViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0];
destViewController.img = [marbleImages objectAtIndex:indexPath.row];
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
및 상세보기 is :
당신이 제공 할 수있는 도움에 감사드립니다. 나는 정말 감사하고 있습니다. - 뭔가를 호출하지 않는
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageView.image = [UIImage imageNamed:img];
}
이것은 이름에 좋은 교훈이 될해야합니다
어떤 오류가 발생했는지 말하지 않았습니다. – meda
면제 중단 점이 있고 중단 점 1.1 충돌 지점은 줄 self.imageView.image = img;입니다. 이것은 (lldb) 이외의 로그 오류에 대해서는 아무 것도 말하지 않습니다 – David