I assigned a button to push a segue to another view controller but when I execute this part of the code I get the following:
2014-02-20 10:44:29.357 nar[20244:70b] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
*** First throw call stack:
(
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 UIKit 0x0076eca5 -[UIStoryboardPushSegue destinationContainmentContext] + 0
3 UIKit 0x0075f07e -[UIStoryboardSegueTemplate _perform:] + 174
4 UIKit 0x0075f0f9 -[UIStoryboardSegueTemplate perform:] + 115
5 libobjc.A.dylib 0x014ce874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003240c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00324484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00323733 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x0059ec7f _UIGestureRecognizerUpdate + 7166
12 UIKit 0x0026919a -[UIWindow _sendGesturesForEvent:] + 1291
13 UIKit 0x0026a0ba -[UIWindow sendEvent:] + 1030
14 UIKit 0x0023de86 -[UIApplication sendEvent:] + 242
15 UIKit 0x0022818f _UIApplicationHandleEventQueue + 11421
16 CoreFoundation 0x016c283f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
17 CoreFoundation 0x016c21cb __CFRunLoopDoSources0 + 235
18 CoreFoundation 0x016df29e __CFRunLoopRun + 910
19 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123
21 GraphicsServices 0x036de9e2 GSEventRunModal + 192
22 GraphicsServices 0x036de809 GSEventRun + 104
23 UIKit 0x0022ad3b UIApplicationMain + 1225
24 w1nnar 0x00002f2d main + 141
25 libdyld.dylib 0x01d7770d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
And I get taken to my main file main.m and it highlights the following:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Not sure what the issue is?
Suggestions and thoughts?
You're trying to push from a UIViewController not being embed in a UINavigationController.
What you need to do is go to your storyboard, select the UIViewController you're trying to push from, go to the Editor menu, select Embed in, and Navigation Controller. Then you can push other UIViewControllers on it.
For information on navigation in iOS apps, read Apple's documentation.
You need a UINavigationController to embed your current view. Since Segues use navigation controllers to push other view controllers on top of it.
If you're using a storyboard, add a UINavigationController and embed your view in it.
Related
I've got a tab ViewController(A) with 5 child view controllers(B) i want to pass from one of my child view controller to another view controller that i've got in my storyboard (C)
I made a button in a child view controller(B) and linked it to my (C) with push in my storyboard but when i click it this is what i get:
2015-07-04 16:04:36.641 LoginSampleFB[1447:74036] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d2c2c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010cf5bbb7 objc_exception_throw + 45
2 UIKit 0x000000010bd37d72 -[UIStoryboardPushSegue destinationContainmentContext] + 0
3 UIKit 0x000000010b7ead62 -[UIApplication sendAction:to:from:forEvent:] + 75
4 UIKit 0x000000010b8fc50a -[UIControl _sendActionsForEvents:withEvent:] + 467
5 UIKit 0x000000010b8fb8d9 -[UIControl touchesEnded:withEvent:] + 522
6 UIKit 0x000000010b837958 -[UIWindow _sendTouchesForEvent:] + 735
7 UIKit 0x000000010b838282 -[UIWindow sendEvent:] + 682
8 UIKit 0x000000010b7fe541 -[UIApplication sendEvent:] + 246
9 UIKit 0x000000010b80bcdc _UIApplicationHandleEventFromQueueEvent + 18265
10 UIKit 0x000000010b7e659c _UIApplicationHandleEventQueue + 2066
11 CoreFoundation 0x000000010d1f6431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
12 CoreFoundation 0x000000010d1ec2fd __CFRunLoopDoSources0 + 269
13 CoreFoundation 0x000000010d1eb934 __CFRunLoopRun + 868
14 CoreFoundation 0x000000010d1eb366 CFRunLoopRunSpecific + 470
15 GraphicsServices 0x000000010fab8a3e GSEventRunModal + 161
16 UIKit 0x000000010b7e98c0 UIApplicationMain + 1282
17 LoginSampleFB 0x000000010b4533ef main + 111
18 libdyld.dylib 0x000000010db5a145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You should add UINavigationControllers as your tabs, and use the ViewControllers (B) as roots for these navigation controllers. Only that way can you perform a push. Otherwise you have to use a modal presentation which will cover partially or entirely your Tab bar controller.
> 2014-09-20 18:04:45.564 storyboard_demo[6919:60b] nested push
animation can result in corrupted navigation bar 2014-09-20
18:04:45.921 storyboard_demo[6919:60b] Finishing up a navigation
transition in an unexpected state. Navigation Bar subview tree might
get corrupted. 2014-09-20 18:04:46.442 storyboard_demo[6919:60b] *
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Receiver
() has no segue with identifier
'third''
* First throw call stack: ( 0 CoreFoundation 0x017ed1e4 exceptionPreprocess + 180 1 libobjc.A.dylib
0x0156c8e5 objc_exception_throw + 44 2 UIKit
0x0034d48c -[UIViewController
shouldPerformSegueWithIdentifier:sender:] + 0 3 storyboard_demo
0x0000254e -[secondViewController btn_second:] + 110 4
libobjc.A.dylib 0x0157e880 -[NSObject
performSelector:withObject:withObject:] + 77 5 UIKit
0x0022e3b9 -[UIApplication sendAction:to:from:forEvent:] + 108 6
UIKit 0x0022e345 -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 61 7 UIKit
0x0032fbd1 -[UIControl sendAction:to:forEvent:] + 66 8 UIKit
0x0032ffc6 -[UIControl _sendActionsForEvents:withEvent:] + 577 9
UIKit 0x0032f243 -[UIControl
touchesEnded:withEvent:] + 641 10 UIKit
0x0026dddd -[UIWindow _sendTouchesForEvent:] + 852 11 UIKit
0x0026e9d1 -[UIWindow sendEvent:] + 1117 12 UIKit
0x002405f2 -[UIApplication sendEvent:] + 242 13 UIKit
0x0022a353 _UIApplicationHandleEventQueue + 11455 14 CoreFoundation
0x0177677f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 15 15 CoreFoundation 0x0177610b __CFRunLoopDoSources0 + 235 16 CoreFoundation 0x017931ae __CFRunLoopRun + 910 17 CoreFoundation
0x017929d3 CFRunLoopRunSpecific + 467 18 CoreFoundation
0x017927eb CFRunLoopRunInMode + 123 19 GraphicsServices
0x037e15ee GSEventRunModal + 192 20 GraphicsServices
0x037e142b GSEventRun + 104 21 UIKit
0x0022cf9b UIApplicationMain + 1225 22 storyboard_demo
0x00002e4d main + 141 23 libdyld.dylib
0x01e3470d start + 1 24 ???
0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught
exception of type NSException
(lldb)
Do it in two steps.
btn_second: can post a notification that it has been pressed and then return to 'first'. 'first' receives the notification and sets a flag. In viewWillAppear, 'first' checks the flag and does a 'third' segue if it's set.
I know there is already a question about this, but the answer provided did not solve my problem.
For start, I had 3 three segues pointing to 3 different view controllers and coming from the AMSlideMenuLeftTableViewController class. The first segue and view controller that I created was the view that appeared as the first view (the one that shows when the app loads).
However, since I deleted that first view my app crashes immediately after opening it up.
This is the crash log:
2014-09-02 17:17:56.200 App[3174:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MenuViewController>: 0x10db0da10>) has no segue with identifier 'rightMenu''
*** First throw call stack:
(
0 CoreFoundation 0x0000000100433495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001030f499e objc_exception_throw + 43
2 UIKit 0x0000000101d99515 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 App 0x000000010002d67f -[AMSlideMenuMainViewController setup] + 1071
4 App 0x000000010002aae1 -[AMSlideMenuMainViewController viewDidLoad] + 353
5 App 0x00000001000915e6 -[MenuViewController viewDidLoad] + 54
6 UIKit 0x0000000101d9759e -[UIViewController loadViewIfRequired] + 562
7 UIKit 0x0000000101d97777 -[UIViewController view] + 29
8 UIKit 0x00000001020a22e2 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 390
9 UIKit 0x0000000101cddffa -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1109
10 UIKit 0x0000000101cddb9f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 36
11 UIKit 0x0000000101cddaef -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 101
12 UIKit 0x0000000101cdcdfe -[UIWindow _updateToInterfaceOrientation:duration:force:] + 377
13 UIKit 0x0000000101d9b70a -[UIViewController _tryBecomeRootViewControllerInWindow:] + 147
14 UIKit 0x0000000101cd7b1b -[UIWindow addRootViewControllerViewIfPossible] + 490
15 UIKit 0x0000000101cd7c70 -[UIWindow _setHidden:forced:] + 282
16 UIKit 0x0000000101ce0ffa -[UIWindow makeKeyAndVisible] + 51
17 UIKit 0x0000000101c9cc98 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1788
18 UIKit 0x0000000101ca0a0c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 660
19 UIKit 0x0000000101cb1d4c -[UIApplication handleEvent:withNewEvent:] + 3189
20 UIKit 0x0000000101cb2216 -[UIApplication sendEvent:] + 79
21 UIKit 0x0000000101ca2086 _UIApplicationHandleEvent + 578
22 GraphicsServices 0x0000000104eff71a _PurpleEventCallback + 762
23 GraphicsServices 0x0000000104eff1e1 PurpleEventCallback + 35
24 CoreFoundation 0x00000001003b5679 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
25 CoreFoundation 0x00000001003b544e __CFRunLoopDoSource1 + 478
26 CoreFoundation 0x00000001003de903 __CFRunLoopRun + 1939
27 CoreFoundation 0x00000001003ddd83 CFRunLoopRunSpecific + 467
28 UIKit 0x0000000101ca02e1 -[UIApplication _run] + 609
29 UIKit 0x0000000101ca1e33 UIApplicationMain + 1010
30 App 0x0000000100076503 main + 115
31 libdyld.dylib 0x0000000103ddd5fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I think the problem is that the app is trying to display the view I deleted as the main view but it isn't there. The fact is that I have not found any reference to that old view I deleted.
If AMSlideMenu catches an exception when trying to create LeftMenu, it then tries to create RightMenu (I don't understand why, but is true).
In my case the left menu firstSegue pointed to a 'wrong view', because it was a simple view controller, not a navigation controller. I changed the view controller to a navigation controller (that points to my original view controller), and that fixed it.
Copy the AMSlideMenuWithoutStoryboard-Prefix.pch file settings to the PCH file from your project.
I was messing with my storyboard with no code involved and got this error after I connected "Terms of use" button to a view controller. It was working fine before this action.
-I created and connected a class to Terms of Use View Controller
-I used action push segue to connect
2014-01-22 17:26:45.434 Project[1162:a0b] -[AboutViewController termsOfUseButton:]: unrecognized selector sent to instance 0x8c89d40
2014-01-22 17:26:45.437 Project[1162:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AboutViewController termsOfUseButton:]: unrecognized selector sent to instance 0x8c89d40'
*** First throw call stack:
(
0 CoreFoundation 0x0173b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014be8b6 objc_exception_throw + 44
2 CoreFoundation 0x017d8903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172b90b ___forwarding___ + 1019
4 CoreFoundation 0x0172b4ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x014d0874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022e0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022e04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003260c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00326484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00325733 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x0026b51d -[UIWindow _sendTouchesForEvent:] + 852
12 UIKit 0x0026c184 -[UIWindow sendEvent:] + 1232
13 UIKit 0x0023fe86 -[UIApplication sendEvent:] + 242
14 UIKit 0x0022a18f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x016c483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x016c41cb __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x016e129e __CFRunLoopRun + 910
18 CoreFoundation 0x016e0ac3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x016e08db CFRunLoopRunInMode + 123
20 GraphicsServices 0x036909e2 GSEventRunModal + 192
21 GraphicsServices 0x03690809 GSEventRun + 104
22 UIKit 0x0022cd3b UIApplicationMain + 1225
23 Project 0x00003a9d main + 141
24 libdyld.dylib 0x01d77725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
(Lame but I found the solution after I finished writing the question)
The reason for this error is I created an IBAction-UIButton method on touch up inside.
I deleted that code and hoped the traces were deleted.
It seems it wasnt, I had to unconnect the touch up inside by clicking the X in red squared spot.
I would try recreating the button and the segue, maybe you changed the IBOutlet name by accident or any other thing.
GL HF
I'm trying to unwind segue form a scene. It works fine but I need to get a value to the parent screen. (I use the push segue to navigate from parent to child scene)
I'm calling the unwind segue like this
- (IBAction)done:(UIStoryboardSegue *)segue {
NSLog(#"gonna navigate");
RESTToppingTableViewController *vc = [segue destinationViewController];
[self setSelectedToppings:[vc toppingList]];
NSLog(#"%#", [vc toppingList]);
}
But the issue is, it seems the toppingList array is removed from memory even before the parent view is called.
Below is the error I got.
2013-12-06 13:26:42.192 Pizza to Go[2319:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RESTAddToCartViewController toppingList]: unrecognized selector sent to instance 0x9b681a0'
*** First throw call stack:
(
0 CoreFoundation 0x01f405e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01cc38b6 objc_exception_throw + 44
2 CoreFoundation 0x01fdd903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01f3090b ___forwarding___ + 1019
4 CoreFoundation 0x01f304ee _CF_forwarding_prep_0 + 14
5 Pizza to Go 0x0004a3a2 -[RESTAddToCartViewController done:] + 130
6 libobjc.A.dylib 0x01cd581f -[NSObject performSelector:withObject:] + 70
7 UIKit 0x010d01f1 -[UIStoryboardUnwindSegueTemplate _perform:] + 536
8 UIKit 0x00f660f9 -[UIStoryboardSegueTemplate perform:] + 115
9 libobjc.A.dylib 0x01cd5874 -[NSObject performSelector:withObject:withObject:] + 77
10 UIKit 0x00a330c2 -[UIApplication sendAction:to:from:forEvent:] + 108
11 UIKit 0x00d07c9b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
12 libobjc.A.dylib 0x01cd5874 -[NSObject performSelector:withObject:withObject:] + 77
13 UIKit 0x00a330c2 -[UIApplication sendAction:to:from:forEvent:] + 108
14 UIKit 0x00a3304e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
15 UIKit 0x00b2b0c1 -[UIControl sendAction:to:forEvent:] + 66
16 UIKit 0x00b2b484 -[UIControl _sendActionsForEvents:withEvent:] + 577
17 UIKit 0x00b2a733 -[UIControl touchesEnded:withEvent:] + 641
18 UIKit 0x00a7051d -[UIWindow _sendTouchesForEvent:] + 852
19 UIKit 0x00a71184 -[UIWindow sendEvent:] + 1232
20 UIKit 0x00a44e86 -[UIApplication sendEvent:] + 242
21 UIKit 0x00a2f18f _UIApplicationHandleEventQueue + 11421
22 CoreFoundation 0x01ec983f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23 CoreFoundation 0x01ec91cb __CFRunLoopDoSources0 + 235
24 CoreFoundation 0x01ee629e __CFRunLoopRun + 910
25 CoreFoundation 0x01ee5ac3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x01ee58db CFRunLoopRunInMode + 123
27 GraphicsServices 0x03e159e2 GSEventRunModal + 192
28 GraphicsServices 0x03e15809 GSEventRun + 104
29 UIKit 0x00a31d3b UIApplicationMain + 1225
30 Pizza to Go 0x000574ad main + 141
31 libdyld.dylib 0x0285e725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What could be the possible fix? thanks for your time in advance.
I'm not sure but I think your destinationViewController isn't a RESTToppingTableViewController.
The log:
-[RESTAddToCartViewController toppingList]:
unrecognized selector sent to instance 0x9b681a0
states that you are trying to get the toppingList of a RESTAddToCartViewController but this controller has no toppingList property.
Make sure that the UIViewController returned by [segue destinationViewController] really is what you are expecting.