我正在加载UIPageViewControllerInside View,但是当我尝试旋转
崩溃日志:
*** Assertion failure in -[UIPageViewController willAnimateRotationToInterfaceOrientation:duration:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UIPageViewController.m:1089
2019-05-28 10:58:17.615007+0530 MyIndia[3263:54878] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No view controllers'
*** First throw call stack:
(
0 CoreFoundation 0x00000001086191bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010760b735 objc_exception_throw + 48
2 CoreFoundation 0x0000000108618f42 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000106291877 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 UIKitCore 0x000000010d8544d4 -[UIPageViewController willAnimateRotationToInterfaceOrientation:duration:] + 4122
5 UIKitCore 0x000000010d90634b -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 294
6 UIKitCore 0x000000010d9021a5 -[_UIViewControllerTransitionContext __runAlongsideAnimations] + 182
7 UIKitCore 0x000000010e3d1bf2 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 558
8 UIKitCore 0x000000010e3d20cf +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 99
9 UIKitCore 0x000000010d91bc44 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke_2 + 278
10 UIKitCore 0x000000010e3d666b +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:] + 187
11 UIKitCore 0x000000010d91b9fd __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke + 128
12 UIKitCore 0x000000010e3d1bf2 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 558
13 UIKitCore 0x000000010e3d20cf +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 99
14 UIKitCore 0x000000010d91b8f9 -[_UIWindowRotationAnimationController animateTransition:] + 480
15 UIKitCore 0x000000010df35dbe -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 527
16 UIKitCore 0x000000010df38964 -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 1780
17 UIKitCore 0x000000010df3938b -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 785
18 UIKitCore 0x000000010df381c7 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 123
19 UIKitCore 0x000000010df36d55 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 112
20 UIKitCore 0x000000010df36c13 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 456
21 CoreFoundation 0x0000000108558bac __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
22 CoreFoundation 0x000000010855802f _CFXRegistrationPost + 447
23 CoreFoundation 0x0000000108557d71 ___CFXNotificationPost_block_invoke + 225
24 CoreFoundation 0x000000010863eae2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1826
25 CoreFoundation 0x0000000108557694 _CFXNotificationPost + 964
26 Foundation 0x00000001062f3589 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
27 UIKitCore 0x000000010db3e68d -[UIDevice setOrientation:animated:] + 288
28 UIKitCore 0x000000010d713e67 __124-[_UICanvasDeviceOrientationSettingsDiffAction _updateDeviceOrientationWithSettingObserverContext:canvas:transitionContext:]_block_invoke + 85
29 UIKitCore 0x000000010d715ba7 _performChangesWithTransitionContext + 908
30 UIKitCore 0x000000010d713de0 -[_UICanvasDeviceOrientationSettingsDiffAction _updateDeviceOrientationWithSettingObserverContext:canvas:transitionContext:] + 245
31 UIKitCore 0x000000010d713c78 __133-[_UICanvasDeviceOrientationSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 112
32 UIKitCore 0x000000010d71580e _performActionsWithDelayForTransitionContext + 100
33 UIKitCore 0x000000010d713bcb -[_UICanvasDeviceOrientationSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 165
34 UIKitCore 0x000000010d71993a -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
35 UIKitCore 0x000000010da961f5 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 502
36 FrontBoardServices 0x0000000114137fdb __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.359 + 213
37 libdispatch.dylib 0x000000010b4c9602 _dispatch_client_callout + 8
38 libdispatch.dylib 0x000000010b4ccb78 _dispatch_block_invoke_direct + 301
39 FrontBoardServices 0x0000000114176ba8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
40 FrontBoardServices 0x0000000114176860 -[FBSSerialQueue _performNext] + 457
41 FrontBoardServices 0x0000000114176e40 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
42 CoreFoundation 0x000000010857e721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
43 CoreFoundation 0x000000010857df93 __CFRunLoopDoSources0 + 243
44 CoreFoundation 0x000000010857863f __CFRunLoopRun + 1263
45 CoreFoundation 0x0000000108577e11 CFRunLoopRunSpecific + 625
46 GraphicsServices 0x00000001111901dd GSEventRunModal + 62
47 UIKitCore 0x000000010def481d UIApplicationMain + 140
48 MyIndia 0x00000001054cd857 main + 71
49 libdyld.dylib 0x000000010b53f575 start + 1
50 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我已经尝试过此解决方案:
override func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
self.pageViewController.view.setNeedsLayout()
if let epaper = self.viewModel.ePapers.first
{
let vc = Storyboard.loadEPaperSlidingVC()
vc.pageIndex = 0
vc.ePapper = epaper
if !isTransiting
{
self.pageViewController.setViewControllers([vc], direction: .forward, animated: false, completion: { (isCompleted ) in
self.isTransiting = !isCompleted
})
}
}else
{
if !isTransiting
{
self.pageViewController.setViewControllers([UIViewController()], direction: .forward, animated: false, completion: { (isCompleted ) in
self.isTransiting = !isCompleted
})
}
}
}