无法使某种视图出队:带有标识符的 UICollectionElementKindCell

2024-01-08

我有 UICollectionView,但似乎我设置的一切都是正确的。但我收到错误:

'could not dequeue a view of kind: UICollectionElementKindCell with identifier PeopleCellForList  - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

我的故事板:

我的代码是:

@interface PeopleCellForList : UICollectionViewCell

@end

@implementation PeopleCellForList

@end


#pragma mark - UICollectionView Datasource

- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
    return self.arrayPeople.count;
}

- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"PeopleCellForList " forIndexPath:indexPath];
    return cell;
}

#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

}
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {

}

#pragma mark – UICollectionViewDelegateFlowLayout

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {

    CGFloat width = 106;
    CGFloat height = width;
    if (indexPath.row % 3 == 2) {
        width = 108;
    }
    return CGSizeMake(width, height);
}

- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

I tried [self.collectionViewMain registerClass:[PeopleCellForList class] forCellWithReuseIdentifier:@"PeopleCellForList"] in viewDidLoad:(在此期间,我尝试从故事板中删除而不是删除单元格),但这没有帮助。


你有一个额外的空间@"PeopleCellForList "

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法使某种视图出队:带有标识符的 UICollectionElementKindCell 的相关文章

  • 自定义 URL 方案不是 Outlook 中的链接 (iOS/Android)

    我们的应用程序可以使用自定义 URL 方案启动 例如myapp mainpage param 123 当它作为链接包含在网页中时 此功能有效 而且 在 iOS 上 它可以在平台附带的邮件客户端中运行 用户注册并安装该应用程序后 他会收到一封
  • SwiftUI 键盘工具栏有条件

    不确定这是否是一个错误或者我是否做错了什么 但如果我使用 toolbar ToolbarItemGroup placement navigationBarLeading if isFocused zipCode Text Test 当等于
  • Android:iOS UIActionSheet 等效项

    我正在转换一个 iOS 应用程序 并且需要实现从 iOS 到 Android 的 UIActionSheet 的等效项 什么 UI 元素最能模仿这一点 我的目标是 Android 2 2 及更高版本 您将使用 AlertDialog 或 D
  • 反应本机套接字 io 没有从客户端发出事件

    尝试将socket io client与react native 现在是ios 一起使用 到目前为止 连接 从客户端接收服务器端事件似乎工作正常 但是我似乎无法从客户端发出任何事件 Client var socket io http loc
  • 如何在松开按钮后立即看到新的视频层?

    我有一个应用程序 用户可以按住按钮来拍摄视频 然而 当他们这样做时 带有视频播放的新图层不会立即出现 相反 有一个非常短的延迟 在用户松开按钮后 您可以看到相机仍然显示相机所看到的内容 延迟结束后 视频立即显示并开始播放 但是 我怎样才能使
  • UILocalNotification 播放自定义声音

    我在我的应用程序中实现了本地通知 但我只是想知道是否有一种方法可以播放不属于 iPhone 应用程序主包的一部分的声音 基本上在我的应用程序中 我希望用户录制生成本地通知时播放的声音 而不是播放预先录制的或默认的声音 据我所知 这是可以实现
  • 使用 iOS 7 检索设备 WiFi MAC 地址

    我们的应用程序使用设备 WiFi MAC 地址来唯一标识设备 根据苹果文档 https developer apple com news id 8222013a我们将开始使用 UIDevice 的identifierForVendor 属性
  • iOS 中的内存泄漏,AVPlayer 永远不会被释放

    我使用了 AVPlayerDemo 示例苹果文档 https developer apple com library ios samplecode AVPlayerDemo Introduction Intro html并在其上编写了我自己
  • iPad 2 检测

    由于我没有 iPad 2 因此我需要知道调用 UIDevice currentDevice model 时它返回什么 我以为它只返回 iPad 但看来我错了 有人可以告诉我吗 Thanks 检查是否有带摄像头的 iPad BOOL isIP
  • 什么是已弃用的推送转场? (iOS 8)[重复]

    这个问题在这里已经有答案了 我不知道在这种情况下已弃用意味着什么 我是编程新手 正在 Xcode 6 中制作我的前几个应用程序 今天我正在制作一个待办事项列表应用程序 当连接到用户可以输入新待办事项以添加到主表的场景时 我被邀请使用推送转场
  • iOS推送通知:当应用程序处于后台时,如何检测用户是否点击了通知?

    关于这个主题有很多 stackoverflow 线程 但我仍然没有找到好的解决方案 如果应用程序不在后台 我可以检查launchOptions UIApplicationLaunchOptionsRemoteNotificationKey
  • 如何在 UIAlertView (iOS) 中的其他两个按钮(堆叠)之间添加取消按钮

    我正在尝试创建一个带有三个按钮 将堆叠 的 UIAlertView 我希望 取消 按钮位于其他两个按钮之间的中间 我尝试将 cancelButtonIndex 设置为 1 但如果还有其他两个按钮 它只会将它们放置在索引 0 和 1 处 我知
  • 在完成块中保留循环

    在我的课堂上 我创建了这个方法 void refreshDatasourceWithSuccess CreateDataSourceSuccessBlock successBlock failure CreateDataSourceFail
  • 如何检测 UISwipeGestureRecognizer 的结束?

    来自苹果文档 滑动是一种离散手势 因此每个手势仅发送一次关联的操作消息 void touchesEnded NSSet touches withEvent UIEvent event 当我使用 UISwipeGestureRecognize
  • NSCFData isRessized 崩溃?

    我目前在控制台中收到此崩溃日志 2011 08 23 19 18 40 064 App 1697 707 NSCFData isResizable unrecognized selector sent to instance 0x11f1c
  • 使用 Protobuf-net,我收到有关 List 未知线路类型的异常

    我已经开始将 Unity iOS 游戏转换为使用 Protobuf net 保存状态 看起来一切正常 直到我将此实例变量添加到GameState ProtoMember 10 public List
  • mgwt - 以编程方式改变方向

    是否可以在 gwt mgwt 应用程序中更改强制执行特定的屏幕方向 可以说我希望用户始终以横向模式使用应用程序 这取决于 是作为phonegap应用程序 而不是在浏览器内部 如果您作为 Web 应用程序运行 则不需要t get any co
  • Admob 广告无法快速显示

    您好 我正在尝试将 admob 广告添加到已使用 swift 上传到应用商店的应用程序中 我在 admob 中制作了一个应用程序并复制了 appid 和广告 id 并显示了各自的横幅广告和插页式广告 这里的问题是当我写这行时 request
  • UITableView:显示 tableFooterView 时运行代码?

    我正在使用 UIView表页脚视图 http developer apple com library ios documentation uikit reference UITableView Class Reference Referen
  • 使用 NSString 进行 UTF8 解码

    我是 Objective C 新手 尝试使用以下示例将格式错误的 UTF8 编码 NSString 转换为格式良好的字符串苹果文档 http developer apple com library mac documentation Coc

随机推荐