popover에서 콜렉션 뷰를 원합니다. 먼저 콜렉션 뷰 컨트롤러와 사용자 정의 셀을 설정합니다. 여기에서 프로그램을 시작하면 제대로 작동합니다.popover에서 콜렉션 뷰 사용 iOS
다른보기 컨트롤러에서 컬렉션보기를 내용으로하는 팝 오버 컨트롤러를 만들었습니다. 툴바 버튼을 누르면 popover가 활성화되어야합니다.
다음'could not dequeue a view of kind: UICollectionElementKindCell with identifier CameraSystemCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
내 viewcontroller.m 코드 :
#import "ViewController.h"
#import "CameraSystemMenuViewController.h"
@interface ViewController() <UIPopoverControllerDelegate>
{
CameraSystemMenuViewController *cameraSystemMenu;
UIPopoverController *popoverController;
}
@end
@implementation ViewController
@synthesize cameraSystemButton = _cameraSystemButton;
- (void)viewDidLoad
{
[super viewDidLoad];
UICollectionViewFlowLayout *aFlowLayout = [[UICollectionViewFlowLayout alloc] init];
cameraSystemMenu = [[CameraSystemMenuViewController alloc] initWithCollectionViewLayout:aFlowLayout];
popoverController = [[UIPopoverController alloc] initWithContentViewController:cameraSystemMenu];
[popoverController setDelegate:self];
}
- (IBAction)cameraSystemSelectButton:(id)sender
{
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[popoverController setPopoverContentSize:CGSizeMake(320, 400)];
}
@end
을 그리고 여기 CameraSystemMenuViewController.m 내 cellForItemAtIndexPath입니다 내가 시뮬레이터를 실행하면
나는이 오류가 발생합니다 :
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CameraSystemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CameraSystemCell" forIndexPath:indexPath];
[[cell collectionImageView] setImage:cameraImage];
cell.cameraSystemName.text = [cameraNumbers objectAtIndex:indexPath.item];
return cell;
}
셀 식별자가 정확합니다. & 스토리 보드 셀에 올바른 사용자 정의 클래스가 있습니다. 스토리 보드에있는 사용자 지정 셀을 사용하고 있으므로 등록 할 필요가 없습니다. 무엇을할까요?
그냥 하나의 의심을'CameraSystemMenuViewController'은 collectionViewController은? 스토리 보드에 설치 ??? –