Pass from a child Viewcontroller (Tab) to a view controller - ios

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.

Related

Call a function of an another class (protocol)

I have a Slide out navigation panel (menu) and an another "menu" on my first page.
Slide out Menu:
Index
Page 1
Page 2
Page 3
Page 4
On Index:
Page 1
Page 2
Page 3
Page 4
So the user have access to the pages from the Index or by Sliding (or tap on Icon Menu) to have the menu.
But I have an error: I go to page 1 from the Index, I tap on the Icon Menu to slide out the Menu I tap on index, I go to page 1 again from the Index, and here if I tap again on the Icon Menu, I get error: SIGBRT
(something like that)
I did some breakpoints:
On this line: self.delegate?.pushViewControllerInStack!(UIStoryboard.nosOffresViewController(‌​)!)
And one in the function pushViewControllerInStack
And when I do maniplations, my app read this line self.delegate?.pushViewControllerInStack!(UIStoryboard.nosOffresViewController(‌​)!) but it don't go in the function.
So my view lost the access of the function, but I don't know why and how to fix the issue.
There's a lot of code, you can find a git repository here: https://github.com/Vkt0r/SlideOutSideBarTest
the error:
2015-10-28 09:00:33.038 Solutis[477:5075] -[Solutis.NosOffresViewController menuNosOffresTapped:]: unrecognized selector sent to instance 0x7ff5caf464e0
2015-10-28 09:00:33.045 Solutis[477:5075] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Solutis.NosOffresViewController menuNosOffresTapped:]: unrecognized selector sent to instance 0x7ff5caf464e0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f3b1f65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111268deb objc_exception_throw + 48
2 CoreFoundation 0x000000010f3ba58d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010f307f7a ___forwarding___ + 970
4 CoreFoundation 0x000000010f307b28 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010fdf31fa -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x00000001101d5247 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 152
7 UIKit 0x000000010fdf31fa -[UIApplication sendAction:to:from:forEvent:] + 92
8 UIKit 0x000000010ff57504 -[UIControl sendAction:to:forEvent:] + 67
9 UIKit 0x000000010ff577d0 -[UIControl _sendActionsForEvents:withEvent:] + 311
10 UIKit 0x000000010ff5794b -[UIControl _sendActionsForEvents:withEvent:] + 690
11 UIKit 0x000000010ff56906 -[UIControl touchesEnded:withEvent:] + 601
12 UIKit 0x000000010fe5daa3 -[UIWindow _sendTouchesForEvent:] + 835
13 UIKit 0x000000010fe5e691 -[UIWindow sendEvent:] + 865
14 UIKit 0x000000010fe10752 -[UIApplication sendEvent:] + 263
15 UIKit 0x000000010fdebfcc _UIApplicationHandleEventQueue + 6693
16 CoreFoundation 0x000000010f2de0a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x000000010f2d3fcc __CFRunLoopDoSources0 + 556
18 CoreFoundation 0x000000010f2d3483 __CFRunLoopRun + 867
19 CoreFoundation 0x000000010f2d2e98 CFRunLoopRunSpecific + 488
20 GraphicsServices 0x000000011485bad2 GSEventRunModal + 161
21 UIKit 0x000000010fdf1676 UIApplicationMain + 171
22 Solutis 0x000000010f1b892d main + 109
23 libdyld.dylib 0x0000000111d8092d start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
You linked the action with the bar item
And you commented it:
So it would crash when you try to open the menu at that page.

ibc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

when i run my app, i received this error :
2014-11-10 06:14:05.581 Yoga[4032:110484] user is registered
2014-11-10 06:14:30.552 Yoga[4032:110484] * 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 0x000000010c999f35 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c632bb7 objc_exception_throw + 45
2 UIKit 0x000000010b43e16a -[UIStoryboardPushSegue destinationContainmentContext] + 0
3 UIKit 0x000000010aedc8be -[UIApplication sendAction:to:from:forEvent:] + 75
4 UIKit 0x000000010afe3410 -[UIControl _sendActionsForEvents:withEvent:] + 467
5 UIKit 0x000000010afe27df -[UIControl touchesEnded:withEvent:] + 522
6 UIKit 0x000000010af22308 -[UIWindow _sendTouchesForEvent:] + 735
7 UIKit 0x000000010af22c33 -[UIWindow sendEvent:] + 683
8 UIKit 0x000000010aeef9b1 -[UIApplication sendEvent:] + 246
9 UIKit 0x000000010aefca7d _UIApplicationHandleEventFromQueueEvent + 17370
10 UIKit 0x000000010aed8103 _UIApplicationHandleEventQueue + 1961
11 CoreFoundation 0x000000010c8cf551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
12 CoreFoundation 0x000000010c8c541d __CFRunLoopDoSources0 + 269
13 CoreFoundation 0x000000010c8c4a54 __CFRunLoopRun + 868
14 CoreFoundation 0x000000010c8c4486 CFRunLoopRunSpecific + 470
15 GraphicsServices 0x000000010d3329f0 GSEventRunModal + 161
16 UIKit 0x000000010aedb420 UIApplicationMain + 1282
17 Yoga 0x000000010a840b53 main + 115
18 libdyld.dylib 0x000000010f69b145 start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
somebody can help me pls
add Navigation Controller to your initial view
Select the initial view
Go To Editor--> Embed In --> Navigation Controller.

AMSlideMenu crash: Receiver (<MenuViewController: 0x10db0da10>) has no segue with identifier 'rightMenu'

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.

Issue with pushing a segue

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.

Unrecognized selector sent to instance, Storyboard bug after connecting a button to view controller

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

Resources