ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath

ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath,第1张

概述Crashlytics给了我以下的堆栈跟踪. 崩溃不一致.在所有iOS 9设备上都会发生,但很少发生.无法找出问题的根源. 在我拥有的任何设备上都没有发生过,过去3天一直试图崩溃. Crashed: com.apple.main-thread0 cherish 0x10014ee18 specialized PersonalizeViewContr Crashlytics给了我以下的堆栈跟踪.
崩溃不一致.在所有iOS 9设备上都会发生,但很少发生.无法找出问题的根源.
在我拥有的任何设备上都没有发生过,过去3天一直试图崩溃.

Crashed: com.apple.main-thread0  cherish                        0x10014ee18 specialized PersonalizeVIEwController.collectionVIEw(UICollectionVIEw,cellForItemAtIndexPath : NSIndexPath) -> UICollectionVIEwCell (PersonalizeVIEwController.swift:159)1  cherish                        0x1001497f0 @objc PersonalizeVIEwController.collectionVIEw(UICollectionVIEw,cellForItemAtIndexPath : NSIndexPath) -> UICollectionVIEwCell (PersonalizeVIEwController.swift)2  UIKit                          0x188aef3a8 <redacted> + 4323  UIKit                          0x188311adc <redacted> + 46284  UIKit                          0x18830c808 <redacted> + 2285  UIKit                          0x1882a81e4 <redacted> + 6566  QuartzCore                     0x185c3a994 <redacted> + 1487  QuartzCore                     0x185c355d0 <redacted> + 2928  QuartzCore                     0x185c35490 <redacted> + 329  QuartzCore                     0x185c34ac0 <redacted> + 25210 QuartzCore                     0x185c34820 <redacted> + 50011 QuartzCore                     0x185c2dde4 <redacted> + 8012 CoreFoundation                 0x183104728 <redacted> + 3213 CoreFoundation                 0x1831024cc <redacted> + 37214 CoreFoundation                 0x1831028fc <redacted> + 92815 CoreFoundation                 0x18302cc50 CFRunLoopRunspecific + 38416 GraphiCSServices               0x184914088 GSEventRunModal + 18017 UIKit                          0x188316088 UIApplicationMain + 20418 cherish                        0x100142a50 main (AppDelegate.swift:19)19 libdispatch.dylib              0x182bca8b8 (Missing)

它崩溃的代码是:

func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {        if collectionVIEw.tag == 1 {            (---crash line---) let cell = select_date_collection_vIEw.dequeueReusableCellWithReuseIDentifIEr(PERSONAliZE_SELECT_DATE_ColLECTION_CELL_IDENTIFIER,forIndexPath: indexPath) as! SelectDateCollectionVIEwCell             // Some changes to cell objects            return cell        } else if collectionVIEw.tag == 2 {            let cell = select_time_collection_vIEw.dequeueReusableCellWithReuseIDentifIEr(PERSONAliZE_SELECT_TIME_ColLECTION_CELL_IDENTIFIER,forIndexPath: indexPath) as! SelectTimeCollectionVIEwCell            // Some changes to cell objects            return cell        } else if collectionVIEw.tag == 3 {            let cell = add_customization_collection_vIEw.dequeueReusableCellWithReuseIDentifIEr(PERSONAliZE_ADD_CUSTOMIZATION_ColLECTION_CELL_IDENTIFIER,forIndexPath: indexPath) as! AddCustomizationCollectionVIEwCell            // Some changes to cell objects            return cell        }        let cell: UICollectionVIEwCell = UICollectionVIEwCell()        return cell    }

已在vIEwDIDLoad()中初始化了所有集合视图

select_date_collection_vIEw.registerNib(UINib(nibname: "SelectDateCollectionVIEwCell",bundle: nil),forCellWithReuseIDentifIEr: PERSONAliZE_SELECT_DATE_ColLECTION_CELL_IDENTIFIER)        select_date_collection_vIEw.tag = 1        select_date_collection_vIEw.dataSource = self        select_date_collection_vIEw.delegate = self        select_date_collection_vIEw.showsHorizontalScrollindicator = false        select_date_collection_vIEw.showsverticalScrollindicator = false        select_date_collection_vIEw.reloadData()        select_time_collection_vIEw.registerNib(UINib(nibname: "SelectTimeCollectionVIEwCell",forCellWithReuseIDentifIEr: PERSONAliZE_SELECT_TIME_ColLECTION_CELL_IDENTIFIER)        select_time_collection_vIEw.tag = 2        select_time_collection_vIEw.dataSource = self        select_time_collection_vIEw.delegate = self        select_time_collection_vIEw.showsHorizontalScrollindicator = false        select_time_collection_vIEw.showsverticalScrollindicator = false        hideselectTimeVIEw()        add_customization_collection_vIEw.registerNib(UINib(nibname: "AddCustomizationCollectionVIEwCell",forCellWithReuseIDentifIEr: PERSONAliZE_ADD_CUSTOMIZATION_ColLECTION_CELL_IDENTIFIER)        add_customization_collection_vIEw.tag = 3        add_customization_collection_vIEw.dataSource = self        add_customization_collection_vIEw.delegate = self        add_customization_collection_vIEw.showsHorizontalScrollindicator = false        add_customization_collection_vIEw.showsverticalScrollindicator = false        hIDeCustomizationsVIEw()

错误发生不一致,这是引起关注的主要原因.由于我无法弄清楚出了什么问题,因此itunes或Crashlytics的崩溃日志无济于事.

解决方法 我终于得到了一个正在崩溃的iphone.
原来有几个问题:

iOS,Crashlytics和iTunes的崩溃报告完全没用.代码崩溃的实际位置从未标记过,但在调试模式下崩溃时由xcode标记.所以不要相信crashlytics或itunes生成的报告.

实际问题是我从服务器那里得到了一个’HH:mm:ss’格式的时间,我将其转换为’hh:mm a’格式,因为我想要我的UI的AM,PM.现在iOS所做的伟大事情是,如果用户手机的时间设置为24小时格式,则不会返回AM / PM,应用程序会崩溃,因为我没有检查返回的字符串是否为零.要解决上述问题,我必须将语言环境设置为:

df.locale = NSLocale(localeIDentifIEr: "en_US_POSIX")

问题终于解决了.主要的学习是不依赖于crashlytics或Itunes报告

总结

以上是内存溢出为你收集整理的ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath全部内容,希望文章能够帮你解决ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1072924.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存