Приложение падает при указанном тексте метки в представлении коллекции - PullRequest
0 голосов
/ 02 октября 2018

Приложение рушится на iphone 7 ios 12. Но я проверил на своей собственной системе с такой же конфигурацией (iphone 7 + ios 12), и она работает нормально.

Отчет, который я получаю от crashlytics:

Дата: 2018-10-01T15: 29: 00Z

Версия ОС: 12.0.0 (16A366)

Устройство: iPhone 7

Оперативная память свободна:13,7%

Свободное место на диске: 68,3%

#0. Crashed: com.apple.main-thread
0  VRapid                         0x104a3d0b4 specialized GroupKViewController.getAttributedTime(time:) (GroupKViewController.swift:1095)
1  VRapid                         0x104a3f5fc specialized GroupKViewController.collectionView(_:cellForItemAt:) (GroupKViewController.swift:1211)
2  VRapid                         0x104a32494 @objc GroupKViewController.collectionView(_:cellForItemAt:) (GroupKViewController.swift)
3  UIKitCore                      0x2036df4ac -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 356
4  UIKitCore                      0x2036e37ec -[UICollectionView _updateVisibleCellsNow:] + 4036
5  UIKitCore                      0x2036e888c -[UICollectionView layoutSubviews] + 324
6  UIKitCore                      0x203ced998 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
7  QuartzCore                     0x1db251a34 -[CALayer layoutSublayers] + 184
8  QuartzCore                     0x1db2569c4 CA::Layer::layout_if_needed(CA::Transaction*) + 324
9  QuartzCore                     0x1db1b59d4 CA::Context::commit_transaction(CA::Transaction*) + 340
10 QuartzCore                     0x1db1e42f4 CA::Transaction::commit() + 608
11 QuartzCore                     0x1db1e515c CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
12 CoreFoundation                 0x1d6bfdb94 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
13 CoreFoundation                 0x1d6bf8828 __CFRunLoopDoObservers + 412
14 CoreFoundation                 0x1d6bf8dc8 __CFRunLoopRun + 1264
15 CoreFoundation                 0x1d6bf85b8 CFRunLoopRunSpecific + 436
16 GraphicsServices               0x1d8e6c584 GSEventRunModal + 100
17 UIKitCore                      0x20363f558 UIApplicationMain + 212
18 VRapid                         0x104a19614 main (GroupVCCell.swift:19)
19 libdyld.dylib                  0x1d66b8b94 start + 4

-

#0. Crashed: com.apple.main-thread
0  VRapid                         0x104a3d0b4 specialized GroupKViewController.getAttributedTime(time:) (GroupKViewController.swift:1095)
1  VRapid                         0x104a3f5fc specialized GroupKViewController.collectionView(_:cellForItemAt:) (GroupKViewController.swift:1211)
2  VRapid                         0x104a32494 @objc GroupKViewController.collectionView(_:cellForItemAt:) (GroupKViewController.swift)
3  UIKitCore                      0x2036df4ac -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 356
4  UIKitCore                      0x2036e37ec -[UICollectionView _updateVisibleCellsNow:] + 4036
5  UIKitCore                      0x2036e888c -[UICollectionView layoutSubviews] + 324
6  UIKitCore                      0x203ced998 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
7  QuartzCore                     0x1db251a34 -[CALayer layoutSublayers] + 184
8  QuartzCore                     0x1db2569c4 CA::Layer::layout_if_needed(CA::Transaction*) + 324
9  QuartzCore                     0x1db1b59d4 CA::Context::commit_transaction(CA::Transaction*) + 340
10 QuartzCore                     0x1db1e42f4 CA::Transaction::commit() + 608
11 QuartzCore                     0x1db1e515c CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
12 CoreFoundation                 0x1d6bfdb94 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
13 CoreFoundation                 0x1d6bf8828 __CFRunLoopDoObservers + 412
14 CoreFoundation                 0x1d6bf8dc8 __CFRunLoopRun + 1264
15 CoreFoundation                 0x1d6bf85b8 CFRunLoopRunSpecific + 436
16 GraphicsServices               0x1d8e6c584 GSEventRunModal + 100
17 UIKitCore                      0x20363f558 UIApplicationMain + 212
18 VRapid                         0x104a19614 main (GroupVCCell.swift:19)
19 libdyld.dylib                  0x1d66b8b94 start + 4

#1. com.twitter.crashlytics.ios.binary-images
0  libsystem_kernel.dylib         0x1d6807948 write + 8
1  VRapid                         0x104b1bcc0 __CLSFileWriteWithRetries_block_invoke (CLSFile.m:241)
2  VRapid                         0x104b1bc00 CLSFileLoopWithWriteBlock (CLSFile.m:213)
3  VRapid                         0x104b1beb0 CLSFileWriteToFileDescriptorOrBuffer (CLSFile.m:190)
4  VRapid                         0x104b1c180 CLSFileWriteCollectionStart (CLSFile.m:442)
5  VRapid                         0x104b1c084 CLSFileWriteSectionStart (CLSFile.m:422)
6  VRapid                         0x104b042a0 __CLSBinaryImageChanged_block_invoke (CLSBinaryImage.m:501)
7  libdispatch.dylib              0x1d66a76c8 _dispatch_call_block_and_release + 24
8  libdispatch.dylib              0x1d66a8484 _dispatch_client_callout + 16
9  libdispatch.dylib              0x1d664fc18 _dispatch_lane_serial_drain$VARIANT$mp + 592
10 libdispatch.dylib              0x1d6650760 _dispatch_lane_invoke$VARIANT$mp + 432
11 libdispatch.dylib              0x1d6658f00 _dispatch_workloop_worker_thread + 600
12 libsystem_pthread.dylib        0x1d688a0f0 _pthread_wqthread + 312
13 libsystem_pthread.dylib        0x1d688cd00 start_wqthread + 4

#2. com.apple.root.default-qos
0  libsystem_kernel.dylib         0x1d68040c8 __connect + 8
1  Quickblox                      0x10535bd28 qb_jid + 171224
2  libdispatch.dylib              0x1d66a76c8 _dispatch_call_block_and_release + 24
3  libdispatch.dylib              0x1d66a8484 _dispatch_client_callout + 16
4  libdispatch.dylib              0x1d664b4d8 _dispatch_queue_override_invoke + 680
5  libdispatch.dylib              0x1d6657a60 _dispatch_root_queue_drain + 376
6  libdispatch.dylib              0x1d6658308 _dispatch_worker_thread2 + 128
7  libsystem_pthread.dylib        0x1d688a190 _pthread_wqthread + 472
8  libsystem_pthread.dylib        0x1d688cd00 start_wqthread + 4

#3. com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0x1d67f9ed0 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1d67f93a8 mach_msg + 72
2  CoreFoundation                 0x1d6bfdfb0 __CFRunLoopServiceMachPort + 236
3  CoreFoundation                 0x1d6bf8e4c __CFRunLoopRun + 1396
4  CoreFoundation                 0x1d6bf85b8 CFRunLoopRunSpecific + 436
5  Foundation                     0x1d75ec6a4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6  Foundation                     0x1d75ec514 -[NSRunLoop(NSRunLoop) runUntilDate:] + 88
7  UIKitCore                      0x20359cac0 -[UIEventFetcher threadMain] + 136
8  Foundation                     0x1d771f3b0 __NSThread__start__ + 1040
9  libsystem_pthread.dylib        0x1d68892fc _pthread_body + 128
10 libsystem_pthread.dylib        0x1d688925c _pthread_start + 48
11 libsystem_pthread.dylib        0x1d688cd08 thread_start + 4

#4. Thread
0  libsystem_pthread.dylib        0x1d688ccfc start_wqthread + 190

#5. Thread
0  libsystem_kernel.dylib         0x1d6805b9c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x1d688a114 _pthread_wqthread + 348
2  libsystem_pthread.dylib        0x1d688cd00 start_wqthread + 4

#6. Thread
0  libsystem_kernel.dylib         0x1d6805b9c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x1d688a114 _pthread_wqthread + 348
2  libsystem_pthread.dylib        0x1d688cd00 start_wqthread + 4

#7. AVAudioSession Notify Thread
0  libsystem_kernel.dylib         0x1d67f9ed0 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1d67f93a8 mach_msg + 72
2  CoreFoundation                 0x1d6bfdfb0 __CFRunLoopServiceMachPort + 236
3  CoreFoundation                 0x1d6bf8e4c __CFRunLoopRun + 1396
4  CoreFoundation                 0x1d6bf85b8 CFRunLoopRunSpecific + 436
5  AVFAudio                       0x1dcbd1c4c GenericRunLoopThread::Entry(void*) + 164
6  AVFAudio                       0x1dcbfdd34 CAPThread::Entry(CAPThread*) + 88
7  libsystem_pthread.dylib        0x1d68892fc _pthread_body + 128
8  libsystem_pthread.dylib        0x1d688925c _pthread_start + 48
9  libsystem_pthread.dylib        0x1d688cd08 thread_start + 4

#8. Thread
0  libsystem_pthread.dylib        0x1d688ccfc start_wqthread + 190

#9. Thread
0  libsystem_pthread.dylib        0x1d688ccfc start_wqthread + 190

#10. com.twitter.crashlytics.ios.MachExceptionServer
0  VRapid                         0x104b1cd80 CLSProcessRecordAllThreads (CLSProcess.c:376)
1  VRapid                         0x104b1cd80 CLSProcessRecordAllThreads (CLSProcess.c:376)
2  VRapid                         0x104b1d1f4 CLSProcessRecordAllThreads (CLSProcess.c:407)
3  VRapid                         0x104b0d078 CLSHandler (CLSHandler.m:26)
4  VRapid                         0x104b08390 CLSMachExceptionServer (CLSMachException.c:446)
5  libsystem_pthread.dylib        0x1d68892fc _pthread_body + 128
6  libsystem_pthread.dylib        0x1d688925c _pthread_start + 48
7  libsystem_pthread.dylib        0x1d688cd08 thread_start + 4

#11. AXBundleLoadQueue
0  libsystem_kernel.dylib         0x1d6804350 __getdirentries64 + 8
1  libsystem_c.dylib              0x1d6731398 _readdir_unlocked + 128
2  libsystem_c.dylib              0x1d6731458 readdir + 40
3  CoreFoundation                 0x1d6bcfa74 _CFIterateDirectory + 100
4  CoreFoundation                 0x1d6cc6ebc _CFBundleCopyInfoDictionaryInDirectoryWithVersion + 564
5  CoreFoundation                 0x1d6cc79e4 CFBundleGetInfoDictionary + 164
6  CoreFoundation                 0x1d6bb0630 _CFBundleCreate + 636
7  Foundation                     0x1d75e95a4 -[NSBundle _cfBundle] + 84
8  Foundation                     0x1d762824c -[NSBundle loadAndReturnError:] + 204
9  UIAccessibility                0x1e8990d38 -[NSBundleAccessibility loadAndReturnError:] + 52
10 AccessibilityUtilities         0x1e6d7b9c0 __50-[AXCodeItem loadWithStrategy:onQueue:completion:]_block_invoke_2 + 240
11 libdispatch.dylib              0x1d66a76c8 _dispatch_call_block_and_release + 24
12 libdispatch.dylib              0x1d66a8484 _dispatch_client_callout + 16
13 libdispatch.dylib              0x1d664fc18 _dispatch_lane_serial_drain$VARIANT$mp + 592
14 libdispatch.dylib              0x1d6650760 _dispatch_lane_invoke$VARIANT$mp + 432
15 libdispatch.dylib              0x1d6658f00 _dispatch_workloop_worker_thread + 600
16 libsystem_pthread.dylib        0x1d688a0f0 _pthread_wqthread + 312
17 libsystem_pthread.dylib        0x1d688cd00 start_wqthread + 4

#12. Thread
0  libsystem_pthread.dylib        0x1d688ccfc start_wqthread + 190

#13. com.apple.CoreMotion.MotionThread
0  libsystem_kernel.dylib         0x1d67f9ed0 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1d67f93a8 mach_msg + 72
2  CoreFoundation                 0x1d6bfdfb0 __CFRunLoopServiceMachPort + 236
3  CoreFoundation                 0x1d6bf8e4c __CFRunLoopRun + 1396
4  CoreFoundation                 0x1d6bf85b8 CFRunLoopRunSpecific + 436
5  CoreFoundation                 0x1d6bf9354 CFRunLoopRun + 80
6  CoreMotion                     0x1dc6272cc (Missing)
7  libsystem_pthread.dylib        0x1d68892fc _pthread_body + 128
8  libsystem_pthread.dylib        0x1d688925c _pthread_start + 48
9  libsystem_pthread.dylib        0x1d688cd08 thread_start + 4

#14. com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x1d67f9ed0 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1d67f93a8 mach_msg + 72
2  CoreFoundation                 0x1d6bfdfb0 __CFRunLoopServiceMachPort + 236
3  CoreFoundation                 0x1d6bf8e4c __CFRunLoopRun + 1396
4  CoreFoundation                 0x1d6bf85b8 CFRunLoopRunSpecific + 436
5  CFNetwork                      0x1d7218e18 -[__CoreSchedulingSetRunnable runForever] + 212
6  Foundation                     0x1d771f3b0 __NSThread__start__ + 1040
7  libsystem_pthread.dylib        0x1d68892fc _pthread_body + 128
8  libsystem_pthread.dylib        0x1d688925c _pthread_start + 48
9  libsystem_pthread.dylib        0x1d688cd08 thread_start + 4

Но я не могу обнаружить сбой, как на моем iPhone 7, приложениеработает нормально.

Кто-нибудь может указать возможную причину.

Следующие шаги уже сделаны

  1. Софтперезапустите приложение
  2. Удалите, а затем переустановите приложение

, но, похоже, ничего не работает.

Ниже приведен код для ref

Получить атрибут с временным кодом

    func getAttributedTime(time: String) -> NSAttributedString {

    let attributeString = NSMutableAttributedString.init()
    let timeComp = time.components(separatedBy: " ")
    let timeAttributeString = NSAttributedString.init(string: timeComp[0], attributes: [NSAttributedStringKey.font : UIFont.init(name: "Roboto-Medium", size: 42)!.setFontAccordingToScreenHeight(), NSAttributedStringKey.foregroundColor : KenanteColors.timeCol])
    let pmAttributedString = NSAttributedString.init(string: timeComp[1], attributes: [NSAttributedStringKey.font: UIFont.init(name: "Roboto-Medium", size: 20)!.setFontAccordingToScreenHeight(), NSAttributedStringKey.foregroundColor : KenanteColors.timeCol])
    attributeString.append(timeAttributeString)
    attributeString.append(pmAttributedString)

    return attributeString

}

}

Вызов getAttributedTime в cellForItemAt

let startTime = dateFormatter.date(from: time)?.toLocalTime() ?? Date.init()
        dateFormatter.amSymbol = "am"
        dateFormatter.pmSymbol = "pm"
        dateFormatter.dateFormat = "hh:mm a"
        let startTimeInDate = dateFormatter.string(from: startTime)
        time = startTimeInDate
        cell.timeIcon.attributedText = getAttributedTime(time: time)

1 Ответ

0 голосов
/ 02 октября 2018

вы должны предоставить фрагмент кода, в котором вы назначаете атрибутивный текст для вашего ярлыка, в противном случае это может быть вызвано несколькими причинами, такими как:

1) Вы должны использовать свойство attributedText UILabel

2) Вы можете развернуть пользовательское имя UIFont, пока оно не существует.

Будет более точное решение после того, как вы поделитесь своим кодом.

...