Moving to another view controller in iOS on Button Click - ios

I am very new to iOS and I am still trying to grasp things. I am trying out this simple program in XCode 5 where when a user clicks the button, he will be redirected into another view controller. I did what other forums told other askers to do, but I seem to encounter an error.
Here are my codes:
In ViewController.m:
- (IBAction)button1:(id)sender {
WebServiceViewController *wc = [[WebServiceViewController alloc]
initWithNibName:#"WebServiceViewController"
bundle:nil];
[self.navigationController pushViewController:wc animated:YES];
}
I placed an import "WebServiceViewController.h" in the headers.
Here is the error (not an IDE error message, but not a success either):
Here is the exception:
2013-10-25 02:05:51.904 sample[16318:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Guest/Library/Application Support/iPhone Simulator/7.0/Applications/C6FA1F33-5E11-40C2-8C69-DA368F21CA5F/sample.app> (loaded)' with name 'WebServiceViewController''
*** First throw call stack:
(
0 CoreFoundation 0x017345e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b78b6 objc_exception_throw + 44
2 CoreFoundation 0x017343bb +[NSException raise:format:] + 139
3 UIKit 0x004ca65c -[UINib instantiateWithOwner:options:] + 951
4 UIKit 0x0033cc95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
5 UIKit 0x0033d43d -[UIViewController loadView] + 302
6 UIKit 0x0033d73e -[UIViewController loadViewIfRequired] + 78
7 UIKit 0x0033dc44 -[UIViewController view] + 35
8 UIKit 0x00357a72 -[UINavigationController _startCustomTransition:] + 778
9 UIKit 0x00364757 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
10 UIKit 0x00365349 -[UINavigationController __viewWillLayoutSubviews] + 57
11 UIKit 0x0049e39d -[UILayoutContainerView layoutSubviews] + 213
12 UIKit 0x00294dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014c981f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03aee72a -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03ae2514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03ae2380 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
17 QuartzCore 0x03a4a156 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
18 QuartzCore 0x03a4b4e1 _ZN2CA11Transaction6commitEv + 393
19 QuartzCore 0x03a4bbb4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
20 CoreFoundation 0x016fc53e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
21 CoreFoundation 0x016fc48f __CFRunLoopDoObservers + 399
22 CoreFoundation 0x016da3b4 __CFRunLoopRun + 1076
23 CoreFoundation 0x016d9b33 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x016d994b CFRunLoopRunInMode + 123
25 GraphicsServices 0x036859d7 GSEventRunModal + 192
26 GraphicsServices 0x036857fe GSEventRun + 104
27 UIKit 0x0022a94b UIApplicationMain + 1225
28 sample 0x00002e7d main + 141
29 libdyld.dylib 0x01d70725 start + 0
30 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Furthermore, I'm using storyboard. I have an initial scene where the user logs in. This scene has a navigation controller embedded. After logging in, I'm not gonna use segue since there would be several view controllers that can be loaded, depending on what type of user has logged in. I'm trying to do this simple program since I'm gonna be using it more complexly in the future.
I'm obviously missing something. I hope someone can help me. I'd be very grateful.
EDIT:
This worked for me
WebServiceViewController *wc = [[UIStoryboard storyboardWithName:#"Main" bundle:nil]
instantiateViewControllerWithIdentifier:#"WebServiceViewController"];
[self.navigationController pushViewController:wc animated:YES];
storyboardWithName depends on the storyboard's name.

try this:
WebServiceViewController *wc = [[UIStoryboard storyboardWithName:#"Main_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:#"WebServiceViewController"];
also set storyboardId to WebServiceViewController in Identity Inspector

You know, using a storyboard you can also define a segue that isn't connected directly to a button, name that segue, and then call it programatically like so:
[self performSegueWithIdentifier:#"showWebServiceViewController" sender:nil];
I think this approach is cleaner and more in line with the storyboard way of working.
Of course, depending on which user has logged in you could perform different named segues to get to the approporiate screen.

Related

error "unrecognized selector sent to instance" after custom segue to different storyboard from delegate method

I'm new to iOS programming, and I'm working on a project using storyboards. I'm using custom segues to transition between storyboards, which works fine. I'm performing one of the segues manually after a user enters a number into a UITextField then hits 'Return'. I'm using the following delegate method of the UITextField to handle the 'Return':
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[self performSegueWithIdentifier:#"#MyStoryboardName" sender:self];
return YES;
}
This successfully segues to the new storyboard. My custom segue uses this central method for performing the actual segue:
- (void)perform
{
UIViewController *source = (UIViewController *)self.sourceViewController;
[source.navigationController pushViewController:self.destinationViewController
animated:YES];
[source presentViewController:self.destinationViewController animated:YES completion:];
}
Following the segue though, I get an error "unrecognized selector sent to instance". I think this has something to do with the delegate method trying to complete after I've moved to the ViewController in the new storyboard, when the delegate is now out of scope? Is this what's happening, and if so, how do I fix this? Here is the stack trace (the view controller containing the text field is TimeDelayViewController):
2015-10-07 11:27:06.739 MyApp[584:28455] -[TimeDelayViewController timeDelay:]: unrecognized selector sent to instance 0x7ca80bb0
2015-10-07 11:27:06.804 MyApp[584:28455] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TimeDelayViewController timeDelay:]: unrecognized selector sent to instance 0x7ca80bb0'
*** First throw call stack:
(
0 CoreFoundation 0x01063a94 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0078be02 objc_exception_throw + 50
2 CoreFoundation 0x0106cde3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x00faae3d ___forwarding___ + 1037
4 CoreFoundation 0x00faaa0e _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x007a00b5 -[NSObject performSelector:withObject:withObject:] + 84
6 UIKit 0x013f4c40 -[UIApplication sendAction:to:from:forEvent:] + 118
7 UIKit 0x013f4bbf -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
8 UIKit 0x0158a8fc -[UIControl sendAction:to:forEvent:] + 79
9 UIKit 0x0158ac7c -[UIControl _sendActionsForEvents:withEvent:] + 408
10 UIKit 0x01ea6e48 -[UITextField _resignFirstResponder] + 324
11 UIKit 0x01632e2f -[UIResponder _finishResignFirstResponder] + 347
12 UIKit 0x01ea6c49 -[UITextField _finishResignFirstResponder] + 51
13 UIKit 0x01632eef -[UIResponder resignFirstResponder] + 159
14 UIKit 0x01ea6ae6 -[UITextField resignFirstResponder] + 141
15 UIKit 0x014a2231 -[UIView(Hierarchy) _removeFirstResponderFromSubtree] + 211
16 UIKit 0x014a276f __UIViewWillBeRemovedFromSuperview + 74
17 UIKit 0x014a2598 -[UIView(Hierarchy) removeFromSuperview] + 99
18 UIKit 0x01585de4 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke596 + 996
19 UIKit 0x0157f64a -[UIPresentationController transitionDidFinish:] + 113
20 UIKit 0x01780040 -[_UICurrentContextPresentationController transitionDidFinish:] + 56
21 UIKit 0x015837fc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 224
22 UIKit 0x01ed7a5b -[_UIViewControllerTransitionContext completeTransition:] + 118
23 UIKit 0x01f01c91 -[UIViewControllerBuiltinTransitionViewAnimator transitionViewDidComplete:fromView:toView:removeFromView:] + 74
24 UIKit 0x0157c29e -[UITransitionView notifyDidCompleteTransition:] + 280
25 UIKit 0x0157bf8a -[UITransitionView _didCompleteTransition:] + 1550
26 UIKit 0x0157ebc5 -[UITransitionView _transitionDidStop:finished:] + 121
27 UIKit 0x014873c7 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 247
28 UIKit 0x014877bd -[UIViewAnimationState animationDidStop:finished:] + 90
29 QuartzCore 0x061ebe97 _ZN2CA5Layer23run_animation_callbacksEPv + 305
30 libdispatch.dylib 0x038379cd _dispatch_client_callout + 14
31 libdispatch.dylib 0x0381d018 _dispatch_main_queue_callback_4CF + 910
32 CoreFoundation 0x00fb570e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
33 CoreFoundation 0x00f73454 __CFRunLoopRun + 2356
34 CoreFoundation 0x00f72866 CFRunLoopRunSpecific + 470
35 CoreFoundation 0x00f7267b CFRunLoopRunInMode + 123
36 GraphicsServices 0x03c37664 GSEventRunModal + 192
37 GraphicsServices 0x03c374a1 GSEventRun + 104
38 UIKit 0x013f2cc1 UIApplicationMain + 160
39 MyApp 0x00045d3a main + 138
40 libdyld.dylib 0x03861a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
According to apple docs the perform method is used for doing custom animations in a segue.
Subclasses override this method and use it to perform the animations from the views in sourceViewController to the views in destinationViewController.
I don't think you should be overriding that method if you're just going to call pushViewController and/or presentViewController, instead you should set up which view controllers get pushed or presented in a storyboard.
But I think what could be your error is the fact that you call both - you're trying to present destinationViewController from both the source view controller and source's navigationViewController at the same time.
The problem turned out to be that I'd initially tried to create an action for my UITextField by control-clicking the text field and automatically creating an IBAction in my implementation file. I removed the IBAction method, in order to instead respond to a delegate method of the UITextField, however I didn't remove the identifier which I'd assigned to the UITextField, and the UITextField was still being looked up using this identifier ('timeDelay'). I removed the entry that had automatically been created under 'Sent events' for my UITextField as shown below, and this fixed the issue:
(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString: #"MyStoryboardName"])
{
UIViewController *source = (UIViewController *)self.sourceViewController;
source=segue.destinationViewController;
[self presentViewController:source animated:YES completion:nil];
}
}

App crashes with NSInternalInconsistencyException', reason: 'Could not load NIB in bundle'

Everyone I'm working on a iOS Static Library. when I use this static library in sample app and run it, it crashes with below exception...
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/name/Library/Developer/CoreSimulator/Devices/D982246E-72D6-482F-8E1C-AE3D1BF37607/data/Containers/Bundle/Application/016193F2-36A3-492D-8E7B-CE560FACCF6D/TestApp.app> (loaded)' with name 'OptionsViewController''
*** First throw call stack:
(
0 CoreFoundation 0x0000000107385c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010701ebb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107385b9d +[NSException raise:format:] + 205
3 UIKit 0x0000000107d30171 -[UINib instantiateWithOwner:options:] + 552
4 UIKit 0x0000000107b88718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
5 UIKit 0x0000000107b88d08 -[UIViewController loadView] + 109
6 UIKit 0x0000000107b88f79 -[UIViewController loadViewIfRequired] + 75
7 UIKit 0x0000000107b8940e -[UIViewController view] + 27
8 UIKit 0x0000000107bae297 -[UINavigationController _startCustomTransition:] + 633
9 UIKit 0x0000000107bba3bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
10 UIKit 0x0000000107bbaf0e -[UINavigationController __viewWillLayoutSubviews] + 43
11 UIKit 0x0000000107d05715 -[UILayoutContainerView layoutSubviews] + 202
12 UIKit 0x0000000107ad8a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
13 QuartzCore 0x000000010bcbeec2 -[CALayer layoutSublayers] + 146
14 QuartzCore 0x000000010bcb36d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
15 QuartzCore 0x000000010bcb3546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
16 QuartzCore 0x000000010bc1f886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
17 QuartzCore 0x000000010bc20a3a _ZN2CA11Transaction6commitEv + 462
18 QuartzCore 0x000000010bc210eb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
19 CoreFoundation 0x00000001072b8ca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
20 CoreFoundation 0x00000001072b8c00 __CFRunLoopDoObservers + 368
21 CoreFoundation 0x00000001072aea33 __CFRunLoopRun + 1123
22 CoreFoundation 0x00000001072ae366 CFRunLoopRunSpecific + 470
23 GraphicsServices 0x000000010b7e7a3e GSEventRunModal + 161
24 UIKit 0x0000000107a58900 UIApplicationMain + 1282
25 TestApp 0x0000000106a54bcf main + 111
26 libdyld.dylib 0x0000000109b7f145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I know, generally this error mean that OptionsViewController xib file is not been included in this library/project but guess what? OptionsViewController's .m file present in compile Sources and .h and .xib file present there in copy files of Build Phases of library.
This library was working file with Xcode 6.1. The time I install Xcode 6.3. this crash came in to picture, now it is not working even in Xcode 6.1
Now I'm clueless why my sample app keep crashing. It has been 1 whole day, I have been struggling with this particular issue without any luck.
Any guidance, clue, anything would be highly appreciated.
UPDATE
App not able to find Resources, files, anything from Static Library.
I have to include all .h , .xibs and resources files in to build face of sample app to make it work, which is not a right way to do it I feel.
Try [[OptionsViewController alloc] initWithNibName:#"OptionsViewController" bundle:[NSBundle bundleForClass:[OptionsViewController class]]]; instead.

uncaught exception of type NSException (connections seem fine) - Wenderlich tutorial

I'm a beginner working through Ray Wenderlich's Swift tutorial, Part 2.
The final code for the lesson (and with which I'm receiving the error) is here: http://cdn5.raywenderlich.com/wp-content/uploads/2014/06/TipCalculator-Demo4.zip
When I build the app through Xcode 6.3.2 and run it on the iOS simulator (iPhone 6), I get the error message below (sorry for the poor formatting).
I did a search on both Google and StackOverflow, seems like people often run into similar errors but are able to fix it by going to the view controller, checking the Connections Inspector, and fixing any of the connections that are flagged (e.g., an object being connected to no longer exists).
Note: I don't have any flags in my Connections Inspector -- everything seems fine there, including the connection between resultsTextView and Text View object in the Storyboard (please see attached photo)
Please let me know how to solve this - thanks.
---------See Connection Inspector on far right - looks fine!-----------
http://i.imgur.com/X6eA05F.png
---------Error message---------
2015-06-05 17:07:39.866 TipCalculator[4848:128801] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key resultsTextView.'
* First throw call stack:
(
0 CoreFoundation 0x0000000100216c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101d81bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001002168a9 -[NSException raise] + 9
3 Foundation 0x0000000100634b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010015ed50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x0000000100d8d52b -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x0000000100be5718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x0000000100be5d08 -[UIViewController loadView] + 109
8 UIKit 0x0000000100be5f79 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x0000000100c1601b -[UINavigationController _layoutViewController:] + 44
10 UIKit 0x0000000100c16565 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
11 UIKit 0x0000000100c16664 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
12 UIKit 0x0000000100c17448 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
13 UIKit 0x0000000100c17f0e -[UINavigationController __viewWillLayoutSubviews] + 43
14 UIKit 0x0000000100d62715 -[UILayoutContainerView layoutSubviews] + 202
15 UIKit 0x0000000100b35a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
16 QuartzCore 0x0000000104916ec2 -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000010490b6d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x000000010490b546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000104877886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
20 QuartzCore 0x0000000104878a3a _ZN2CA11Transaction6commitEv + 462
21 UIKit 0x0000000100ab3a2d -[UIApplication _reportMainSceneUpdateFinished:] + 44
22 UIKit 0x0000000100ab46f1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
23 UIKit 0x0000000100ab30d5 -[UIApplication workspaceDidEndTransaction:] + 179
24 FrontBoardServices 0x00000001038915e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
25 CoreFoundation 0x000000010014a41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
26 CoreFoundation 0x0000000100140165 __CFRunLoopDoBlocks + 341
27 CoreFoundation 0x000000010013f947 __CFRunLoopRun + 887
28 CoreFoundation 0x000000010013f366 CFRunLoopRunSpecific + 470
29 UIKit 0x0000000100ab2b42 -[UIApplication _run] + 413
30 UIKit 0x0000000100ab5900 UIApplicationMain + 1282
31 TipCalculator 0x000000010002c177 main + 135
32 libdyld.dylib 0x00000001024d9145 start + 1
33 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Make sure you follow those steps correctly:
Open Main.storyboard and select your View Controller in the Document
Outline. Open the Connections Inspector (6th tab), and you will see
all of the properties you created listed in the Outlets section.
021_ConnectionsInspector You’ll notice a small circle to the right of
resultsTextView. Control-drag from that button down to the text view
below the Calculate button, and release to connect your Swift property
to this view.
I believe you are missing the #IBOutlet that is create in this step

Getting error for passed in UserId in tab controller?

I am not sure why I keep getting this error, I do pass the userId from the profile view controller on a button click with a push:
TotalTabController *userTabView = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"userTabView"];
userTabView.userProfileId = userId;
NSLog(#"the user tota tab is %#", userId);
userTabView.userProfileName = profileName;
[self.navigationController pushViewController:userTabView animated:NO];
The NSLog prints out the correct userID, and then I have it added to the tab controller in the .h file like so:
#interface TotalTabController : UITabBarController {
NSString *userProfileId, *userProfileName;
}
#property (nonatomic, retain) NSString *userProfileId;
#property (nonatomic, retain) NSString *userProfileName;
And in the .m file like so:
#synthesize userProfileId, userProfileName;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(#"the tab loaded and is %#", userProfileId);
}
but the NSLog prints out null in the .m file...
Then I call it in one of the tab views .m file like so:
userProfileId = [(TotalTabController*)self.tabBarController userProfileId];
And then get this error:
The error is:
2014-05-17 11:49:04.667 Example[1108:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0 CoreFoundation 0x01e291e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01ba88e5 objc_exception_throw + 44
2 CoreFoundation 0x01def376 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 390
3 CoreFoundation 0x01e1cc29 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 73
4 Example 0x00012233 -[CreatedCollectionViewController getCreatedNames] + 419
5 Example 0x0001202b -[CreatedCollectionViewController viewDidLoad] + 123
6 UIKit 0x0098733d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x009875d9 -[UIViewController view] + 35
8 UIKit 0x009bf11f -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 407
9 UIKit 0x009be943 -[UITabBarController transitionFromViewController:toViewController:] + 63
10 UIKit 0x009babed -[UITabBarController _setSelectedViewController:] + 281
11 UIKit 0x009baacc -[UITabBarController setSelectedViewController:] + 180
12 UIKit 0x009b7e30 __87-[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:]_block_invoke + 43
13 UIKit 0x008ce81f +[UIView(Animation) performWithoutAnimation:] + 82
14 UIKit 0x009b7cd5 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 247
15 UIKit 0x009b8ae9 -[UITabBarController viewWillAppear:] + 148
16 UIKit 0x0098b04b -[UIViewController _setViewAppearState:isAnimating:] + 448
17 UIKit 0x0098b548 -[UIViewController __viewWillAppear:] + 114
18 UIKit 0x0099c105 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 199
19 UIKit 0x009a1a5e -[UINavigationController _startCustomTransition:] + 1062
20 UIKit 0x009ae8f7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
21 UIKit 0x009af4e9 -[UINavigationController __viewWillLayoutSubviews] + 57
22 UIKit 0x00af00d1 -[UILayoutContainerView layoutSubviews] + 213
23 UIKit 0x008d7964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
24 libobjc.A.dylib 0x01bba82b -[NSObject performSelector:withObject:] + 70
25 QuartzCore 0x0455045a -[CALayer layoutSublayers] + 148
26 QuartzCore 0x04544244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
27 QuartzCore 0x045440b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
28 QuartzCore 0x044aa7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
29 QuartzCore 0x044abb85 _ZN2CA11Transaction6commitEv + 393
30 QuartzCore 0x045695b0 +[CATransaction flush] + 52
31 UIKit 0x008669bb _UIApplicationHandleEventQueue + 13095
32 CoreFoundation 0x01db277f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
33 CoreFoundation 0x01db210b __CFRunLoopDoSources0 + 235
34 CoreFoundation 0x01dcf1ae __CFRunLoopRun + 910
35 CoreFoundation 0x01dce9d3 CFRunLoopRunSpecific + 467
36 CoreFoundation 0x01dce7eb CFRunLoopRunInMode + 123
37 GraphicsServices 0x03be85ee GSEventRunModal + 192
38 GraphicsServices 0x03be842b GSEventRun + 104
39 UIKit 0x00868f9b UIApplicationMain + 1225
40 Stand 0x00013a3d main + 141
41 libdyld.dylib 0x02575701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The ultimate goal is to pass the userID from the profile.m file to the tab controller and allow each tab to have access to the userID, not sure what I am doing wrong, if someone can notice the error or let me know how I can have it so that it is not null and accessible?
Update
I am thinking maybe it has to do with not being able to push a tabcontroller according to apple's guidelines, could that be the case? If so how do I go around it, or what options do I have?
Hi the problem here is that you are trying to push tab bar controller in navigation controller but apple forbids it Link .So you can add the tabbar controller modally or create a custom tab bar in a view controller and push it

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.

Resources