此崩溃只发生在iOS 11上,我不知道如何修复它。
当点击iOS 11的EKCalendarChooser类的新工具栏上的[全部显示]按钮时发生崩溃,但是当它的selectionStyle设置为.single
时:
致命异常: NSInternalInconsistencyException 无效的样式
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x1830e3d38 __exceptionPreprocess
1 libobjc.A.dylib 0x1825f8528 objc_exception_throw
2 CoreFoundation 0x1830e3c0c +[NSException raise:format:]
3 Foundation 0x183a72c24 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 EventKitUI 0x1941ad908 -[EKCalendarChooser _selectAllCalendarsAndStores:]
5 EventKitUI 0x1941a6384 -[EKCalendarChooser showAllButtonPressed]
6 UIKit 0x18c52820c -[UIApplication sendAction:to:from:forEvent:]
7 UIKit 0x18c68253c -[UIBarButtonItem(UIInternal) _sendAction:withEvent:]
8 UIKit 0x18c52820c -[UIApplication sendAction:to:from:forEvent:]
9 UIKit 0x18c52818c -[UIControl sendAction:to:forEvent:]
10 UIKit 0x18c512f4c -[UIControl _sendActionsForEvents:withEvent:]
11 UIKit 0x18c5130b4 -[UIControl _sendActionsForEvents:withEvent:]
12 UIKit 0x18c527a80 -[UIControl touchesEnded:withEvent:]
13 UIKit 0x18cb73ec8 _UIGestureEnvironmentSortAndSendDelayedTouches
14 UIKit 0x18cb6f488 _UIGestureEnvironmentUpdate
15 CoreFoundation 0x18308b8b8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
16 CoreFoundation 0x183089270 __CFRunLoopDoObservers
17 CoreFoundation 0x18308982c __CFRunLoopRun
18 CoreFoundation 0x182faa2d8 CFRunLoopRunSpecific
19 GraphicsServices 0x184e3bf84 GSEventRunModal
20 UIKit 0x18c557880 UIApplicationMain
21 MyApp1 0x104d92be4 main (AppDelegate.swift:15)
22 libdyld.dylib 0x182ace56c start
我想知道有没有办法隐藏新工具栏?
===== 2017年11月19日编辑
添加了屏幕截图以显示新工具栏:
将selectedCalendars
留空后,将显示新工具栏。一旦按下[全部显示]按钮,就会发生崩溃。
答案 0 :(得分:1)
我遇到了同样的错误,并发现了一种奇怪但令人惊讶的有效解决方法。如果您在呈现视图控制器之前清除所选的日历,则工具栏会消失,从而防止崩溃。
calendarChooser.selectedCalendars = Set();