【发布时间】:2013-03-25 13:43:10
【问题描述】:
我想在弹出窗口中有一个集合视图。所以首先我设置了我的 Collection 视图控制器和我的自定义单元格。当我从这里启动程序时,它工作正常。
在另一个视图控制器中,我创建了一个以集合视图作为其内容的弹出框控制器。当我点击工具栏按钮时,弹出框需要变为活动状态。
当我运行模拟器时出现此错误:
' 无法将一种视图出列:UICollectionElementKindCell with 标识符 CameraSystemCell - 必须为 标识符或连接故事板中的原型单元'
这是我的 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?在情节提要中设置???
标签: ios objective-c ipad popover collectionview