Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

UISplitViewController in Xcode

Hey Guys, Im in Xcode with a split view controller and all my code is great without any issues, and i have a home screen before my split view, and when i run the app, and click on a link to go to the split view, it crashes and comes up with the main.main file, and i checked all the links in the Main.Storyboard and they are all good, nothing wrong there, i added an exemption break point, that didn't reveal anything but the same main,main file, and than i tried resetting the Simulator, and still, the same problem, does anyone know where i went wrong or what i can do to try and fix my problem?

Stone Preston
Stone Preston
42,016 Points

there is probably an error message that gets logged to your console after the crash. can you post that?

Stone Preston in the log, the very last thing it says is terminating with uncaught exception of type NSException (lldb)

Stone Preston
Stone Preston
42,016 Points

are you positive thats all that is there? it should give a bit more information (but maybe not) about whats going on.

Stone Preston this is exactly what it says

2014-04-09 13:46:11.745 iFormula[733:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a Split View Controllers modally .' *** First throw call stack: ( 0 CoreFoundation 0x000000010194f495 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001016ae99e objc_exception_throw + 43 2 UIKit 0x000000010035bc93 -[UIViewController presentViewController:withTransition:completion:] + 4027 3 UIKit 0x000000010025cf06 -[UIApplication sendAction:to:from:forEvent:] + 80 4 UIKit 0x000000010025ceb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17 5 UIKit 0x0000000100339880 -[UIControl _sendActionsForEvents:withEvent:] + 203 6 UIKit 0x0000000100338dc0 -[UIControl touchesEnded:withEvent:] + 530 7 UIKit 0x0000000100293d05 -[UIWindow _sendTouchesForEvent:] + 701 8 UIKit 0x00000001002946e4 -[UIWindow sendEvent:] + 925 9 UIKit 0x000000010026c29a -[UIApplication sendEvent:] + 211 10 UIKit 0x0000000100259aed _UIApplicationHandleEventQueue + 9579 11 CoreFoundation 0x00000001018ded21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 12 CoreFoundation 0x00000001018de5f2 __CFRunLoopDoSources0 + 242 13 CoreFoundation 0x00000001018fa46f __CFRunLoopRun + 767 14 CoreFoundation 0x00000001018f9d83 CFRunLoopRunSpecific + 467 15 GraphicsServices 0x0000000103ac6f04 GSEventRunModal + 161 16 UIKit 0x000000010025be33 UIApplicationMain + 1010 17 iFormula 0x0000000100003813 main + 115 18 libdyld.dylib 0x0000000101fe75fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

3 Answers

Stone Preston
Stone Preston
42,016 Points

Ok, then there is your problem right there reason: 'Application tried to present a Split View Controllers modally Basically you need to make the split view controller the root view controller before presenting it using something like

self.window.rootViewController = self.splitViewController;

So, im not able to have say a home screen before the split view controller? Stone Preston

Stone Preston
Stone Preston
42,016 Points

no you should be able to, you just have to change the root view controller whenever you want to show that split view controller. However ive never worked with one before, so this all based on assumption.

Thanks Stone Preston You've been a great help!!!

Stone Preston
Stone Preston
42,016 Points

no problem. Hope you get it working.

Stone Preston this is exactly what it says

2014-04-09 13:46:11.745 iFormula[733:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a Split View Controllers modally <ViewController: 0x109422bf0>.' *** First throw call stack: ( 0 CoreFoundation 0x000000010194f495 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001016ae99e objc_exception_throw + 43 2 UIKit 0x000000010035bc93 -[UIViewController presentViewController:withTransition:completion:] + 4027 3 UIKit 0x000000010025cf06 -[UIApplication sendAction:to:from:forEvent:] + 80 4 UIKit 0x000000010025ceb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17 5 UIKit 0x0000000100339880 -[UIControl _sendActionsForEvents:withEvent:] + 203 6 UIKit 0x0000000100338dc0 -[UIControl touchesEnded:withEvent:] + 530 7 UIKit 0x0000000100293d05 -[UIWindow _sendTouchesForEvent:] + 701 8 UIKit 0x00000001002946e4 -[UIWindow sendEvent:] + 925 9 UIKit 0x000000010026c29a -[UIApplication sendEvent:] + 211 10 UIKit 0x0000000100259aed _UIApplicationHandleEventQueue + 9579 11 CoreFoundation 0x00000001018ded21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 12 CoreFoundation 0x00000001018de5f2 __CFRunLoopDoSources0 + 242 13 CoreFoundation 0x00000001018fa46f __CFRunLoopRun + 767 14 CoreFoundation 0x00000001018f9d83 CFRunLoopRunSpecific + 467 15 GraphicsServices 0x0000000103ac6f04 GSEventRunModal + 161 16 UIKit 0x000000010025be33 UIApplicationMain + 1010 17 iFormula 0x0000000100003813 main + 115 18 libdyld.dylib 0x0000000101fe75fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)