UICollectionView在xcode16编译闪退问题

news/2024/12/4 4:17:32/

使用xcode15运行工程,控制台会出现如下提示:

Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <IQEngUICollectionViewCell: 0x130215e00; baseClass = UICollectionViewCell; frame = (396 0; 396 98.1547); clipsToBounds = YES; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x301e371a0>>; Collection view: <UICollectionView: 0x1300caa00; frame = (0 0; 396 98.1547); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x300b706f0>; backgroundColor = <UIDynamicSystemColor: 0x3002a3380; name = systemBackgroundColor>; layer = <CALayer: 0x301d5a080>; contentOffset: {0, 0}; contentSize: {3168, 98.154666666666671}; adjustedContentInset: {0, 0, 0, 0}; layout: <IQEngCollectionViewFlowLayout: 0x1237e7480>; dataSource: IQEngCarouselView:<IQEngCarouselView: 0x130117e00; frame = (16 11.4133; 396 98.1547); clipsToBounds = YES; layer = <CALayer: 0x301d59f20>>>  This will become an assert in a future version.

然后在xcode16运行是会直接闪退的,控制台会显示

*** Assertion failure in -[UICollectionView _updateVisibleCellsNow:], UICollectionView.m:5673

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <IQEngUICollectionViewCell: 0x1627b4780; baseClass = UICollectionViewCell; frame = (396 0; 396 98.1547); clipsToBounds = YES; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x302bc77a0>>; Collection view: <UICollectionView: 0x15fd0c000; frame = (0 0; 396 98.1547); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x3030c4570>; backgroundColor = <UIDynamicSystemColor: 0x303a1f880; name = systemBackgroundColor>; layer = <CALayer: 0x302663260>; contentOffset: {0.33333333333333331, 0}; contentSize: {3168, 98.154666666666671}; adjustedContentInset: {0, 0, 0, 0}; layout: <IQEngCollectionViewFlowLayout: 0x15fb53480>; dataSource: IQEngCarouselView:<IQEngCarouselView: 0x15fcab800; frame = (16 11.4133; 396 98.1547); clipsToBounds = YES; layer = <CALayer: 0x3026630a0>>>'

问题原因在于,轮播图在自动轮播的时候调用的方法有问题

这个代码是有问题的    
UICollectionViewCell *cell = [self collectionView:self.collectionView cellForItemAtIndexPath:indexPath];CGFloat f1_minX = cell.frame.origin.x;CGPoint point = CGPointZero;point.x = f1_minX;CGPoint nextPoint = [self.collectionViewLayout targetContentOffsetForProposedContentOffset:point withScrollingVelocity:CGPointZero];[self.collectionView setContentOffset:nextPoint animated:animated];

将上面代码换成

    [self.collectionView scrollToItemAtIndexPath:indexPathatScrollPosition:UICollectionViewScrollPositionLeftanimated:animated];

可以解决问题


http://www.ppmy.cn/news/1552176.html

相关文章

YoloV10-yaml文件理解

最近在学习和尝试改进yolov结记录一下原始代码的理解,希望大佬指正.10,在这里总 [1] 论文&#xff1a;https://arxiv.org/abs/2405.14458 [2] 代码&#xff1a;GitHub - THU-MIG/yolov10: YOLOv10: Real-Time End-to-End Object Detection [NeurIPS 2024] YOLOv10的新特性 1. 无…

The selected directory is not a valid home for Go SDK

在idea里配置go语言的环境时&#xff0c;选择go语言的安装目录&#xff0c;一直提示这个 The selected directory is not a valid home for Go SDK后来查了一下&#xff0c;发现原来idea识别不出来 需要改一下配置文件&#xff0c;找到go环境的安装目录&#xff0c;我是默认安…

基于SSM超市商品管理系统JAVA|VUE|Springboot计算机毕业设计源代码+数据库+LW文档+开题报告+答辩稿+部署教+代码讲解

源代码数据库LW文档&#xff08;1万字以上&#xff09;开题报告答辩稿 部署教程代码讲解代码时间修改教程 一、开发工具、运行环境、开发技术 开发工具 1、操作系统&#xff1a;Window操作系统 2、开发工具&#xff1a;IntelliJ IDEA或者Eclipse 3、数据库存储&#xff1a…

【论文阅读】 Learning to Upsample by Learning to Sample

论文结构目录 一、之前的上采样器二、DySample概述三、不同上采样器比较四、整体架构五、设计过程&#xff08;1&#xff09;初步设计&#xff08;2&#xff09;第一次修改&#xff08;3&#xff09;第二次修改&#xff08;4&#xff09;第三次修改 六、DySample四种变体七、复…

什么是sfp,onu,​为什么PON(​俗称“光猫”​)模块使用SC光纤接口

在现代网络设备中&#xff0c;我们经常会看到SFP或SFP接口的身影&#xff0c;这些接口有时被简称为光口&#xff0c;但这个称呼并不严谨。有些厂商则称之为多功能口或多用途口&#xff0c;然而这对于不了解的人来说可能还是一头雾水。SFP&#xff0c;即Small Form-Factor Plugg…

hint: Updates were rejected because the tip of your current branch is behind!

问题 本地仓库往远段仓库推代码时候提示&#xff1a; error: failed to push some refs to 192.168.2.1:java-base/java-cloud.git hint: Updates were rejected because the tip of your current branch is behind! refs/heads/master:refs/heads/master [rejected] (…

软通动力携子公司鸿湖万联、软通教育助阵首届鸿蒙生态大会成功举办

11月23日中国深圳&#xff0c;首届鸿蒙生态大会上&#xff0c;软通动力及软通动力子公司鸿湖万联作为全球智慧物联网联盟&#xff08;GIIC&#xff09;理事单位、鸿蒙生态服务&#xff08;深圳&#xff09;有限公司战略合作伙伴&#xff0c;联合软通教育深度参与了大会多项重磅…

SQL面试题——抖音SQL面试题 股票波峰波谷

SQL面试题——抖音SQL面试题 股票波峰波谷 今天这道题目来自字节,分析股票的波峰波谷,其实我们之前分析过股票的涨停板数据,可以参考之前的文章 股票数据分析 股票打板策略分析 这里稍稍提一句,打板分析,本质上也是一种连续,我们对连续的问题已经分析过很多次了 SQL…