Я хочу иметь представление коллекции в popover. Поэтому сначала я настроил контроллер коллекции и свою пользовательскую ячейку. Когда я запускаю программу отсюда, она работает нормально.Использовать представление коллекции в popover iOS
В другом контроллере представления я создал контроллер popover с представлением коллекции в качестве его содержимого. Когда я нажимаю кнопку панели инструментов, 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
А вот моя cellForItemAtIndexPath в CameraSystemMenuViewController.m:
-(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? настроен в раскадровке ??? –