大佬教程收集整理的这篇文章主要介绍了ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Crashed: com.apple.main-thread 0 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> + 432 3 UIKit 0x188311adc <redacted> + 4628 4 UIKit 0x18830c808 <redacted> + 228 5 UIKit 0x1882a81e4 <redacted> + 656 6 QuartzCore 0x185c3a994 <redacted> + 148 7 QuartzCore 0x185c355d0 <redacted> + 292 8 QuartzCore 0x185c35490 <redacted> + 32 9 QuartzCore 0x185c34ac0 <redacted> + 252 10 QuartzCore 0x185c34820 <redacted> + 500 11 QuartzCore 0x185c2dde4 <redacted> + 80 12 CoreFoundation 0x183104728 <redacted> + 32 13 CoreFoundation 0x1831024cc <redacted> + 372 14 CoreFoundation 0x1831028fc <redacted> + 928 15 CoreFoundation 0x18302cc50 CFRunLoopRunSpecific + 384 16 Graphicsservices 0x184914088 GSEventRunModal + 180 17 UIKit 0x188316088 UIApplicationMain + 204 18 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的崩溃日志无济于事.
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")
以上是大佬教程为你收集整理的ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath全部内容,希望文章能够帮你解决ios – UICollectionView上的Swift专门崩溃cellForItemAtIndexPath所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。