When I run my app, I notice that the setViewController
method causes a memory link and crashes my app.I have worked on this issue for hours, and have tried looking on the web, and found one post, which mentioned putting my setViewController
method in the dispatch_async(dispatch_get_main_queue)
but that terminates the app, and I get the following error in the console:
2015-12-26 19:41:55.596 Harish Yerra[4663:132796] XPC connection interrupted 2015-12-26 19:41:55.596 Harish Yerra[4663:132797] Terminating since there is no system app.
The iPhone than fully restarts and goes back to the home screen.
I have tried commenting out the setViewController
method, and my app loads the first page of the Page View Controller fine, and then when I scroll to the next page it crashes again with the following error:
* Assertion failure in -[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/_UIQueuingScrollView.m:377 2015-12-26 19:31:55.058 Harish Yerra[4381:123817] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [views count] == 3' *** First throw call stack: ( 0 CoreFoundation 0x000000010e411e65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001105b0deb objc_exception_throw + 48 2 CoreFoundation 0x000000010e411cca +[NSException raise:format:arguments:] + 106 3 Foundation 0x000000010ea824de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198 4 UIKit 0x000000010f8d5575 -[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:] + 289 5 UIKit 0x000000010f8d949d -[_UIQueuingScrollView _didScrollWithAnimation:force:] + 1350 6 UIKit 0x000000010f8d4701 -[_UIQueuingScrollView layoutSubviews] + 176 7 UIKit 0x000000010f1444a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703 8 QuartzCore 0x000000010ef4959a -[CALayer layoutSublayers] + 146 9 QuartzCore 0x000000010ef3de70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 10 QuartzCore 0x000000010ef3dcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 11 QuartzCore 0x000000010ef32475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 12 QuartzCore 0x000000010ef5fc0a _ZN2CA11Transaction6commitEv + 486 13 QuartzCore 0x000000010ef6e9f4 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 576 14 CoreFoundation 0x000000010e371c84 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20 15 CoreFoundation 0x000000010e371831 __CFRunLoopDoTimer + 1089 16 CoreFoundation 0x000000010e333241 __CFRunLoopRun + 1937 17 CoreFoundation 0x000000010e332828 CFRunLoopRunSpecific + 488 18 GraphicsServices 0x0000000112219ad2 GSEventRunModal + 161 19 UIKit 0x000000010f08d610 UIApplicationMain + 171 20 Harish Yerra 0x000000010d813efd main + 109 21 libdyld.dylib 0x00000001115f092d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb).
I will provide the code for my viewDidLoad
, but if you need the code for the entire PageViewControllerDataSource, just let me know and I will provide it. Thanks so much for your help.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.pageViewController = harishStoryboard.instantiateViewControllerWithIdentifier("HarishPageViewController") as! UIPageViewController
self.pageViewController.dataSource = self
let initialViewController = harishStoryboard.instantiateInitialViewController() as! HarishIntroduction
let viewController = NSArray(object: initialViewController)
dispatch_async(dispatch_get_main_queue(), {
self.pageViewController.setViewControllers(viewController as? [UIViewController], direction: .Forward, animated: false, completion: nil)
})
self.pageViewController.view.frame = CGRectMake(0, 100, self.view.frame.size.width, self.view.frame.size.height-100)
self.addChildViewController(pageViewController)
self.view.addSubview(self.pageViewController.view)
self.pageViewController.didMoveToParentViewController(self)
}