简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM