When I Navigate to another View Its Perfectly Navigating ..if Again Back the Originaly View when i again click the button to Navigate i got the crash ...I did't Understand what is the Problem Any One Help To solve this Issues
Thanks in Advance
TorunamentVC*TETS = [[TorunamentVC alloc]init];
TETS = (TorunamentVC*)[self.storyboard instantiateViewControllerWithIdentifier:#"tornmentid"];
TETS.selectDashBoard=selectType;
[self.navigationController pushViewController:TETS animated:YES];
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'BYZ-38-t0r-view-8bC-Xf-vdC' and directory 'Main.storyboardc''
* First throw call stack:
TorunamentVC*TETS = [self.storyboard instantiateViewControllerWithIdentifier:#"tornmentid"];
TETS.selectDashBoard=selectType;
[self.navigationController pushViewController:TETS animated:YES];
Try this
Related
I have the below Objective-C code to launch my app with Home Screen Quick Actions:
- (void)applyShortcutItem:(UIApplicationShortcutItem *)shortcutItem
{
ViewController *rootViewController = (ViewController *)[self.window rootViewController];
NSLog(#"Here %# - %#", rootViewController, shortcutItem);
if([shortcutItem.type isEqualToString:#"LaunchMode0"])
{
[rootViewController setShortcutAction:LaunchMode0];
}
else if([shortcutItem.type isEqualToString:#"LaunchMode1"])
{
[rootViewController setShortcutAction:LaunchMode1];
}
}
However, I keep getting runtime errors (unrecognized selected sent to instance) when I try to launch with the quick actions. Notably, it's these two lines where the app seems to trip up:
[rootViewController setShortcutAction:LaunchMode0]; and [rootViewController setShortcutAction:LaunchMode1];
It doesn't seem to like the rootViewController. Technically, the initial View Controller is the Navigation Controller, however the app launches to my main view controller (the app only has two views, the main one, and an about page).
There is more code above that code in my project, but this is the part that's giving me the error-- but let me know if seeing the other code would help (I didn't want the post to be too code heavy).
Thanks so much!
EDIT: as requested, here is the complete NSLog.
2019-09-23 18:18:01.317271-0400 AppName[1719:200993] Here <UINavigationController: 0x108802200> - <UIApplicationShortcutItem: 0x282bd1500; type: Mode1Shortcut, title: Mode 1>
2019-09-23 18:18:01.321819-0400 AppName[1719:200993] -[UINavigationController setShortcutAction:]: unrecognized selector sent to instance 0x108802200
2019-09-23 18:18:01.323462-0400 AppName[1719:200993] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setShortcutAction:]: unrecognized selector sent to instance 0x108802200'
*** First throw call stack:
(0x2045aa98c 0x2037839f8 0x2044c71c8 0x231033220 0x2045b01d4 0x2045b1e6c 0x102c14af0 0x102c148ec 0x230ffdf90 0x2308cc468 0x2308cd150 0x2308cc224 0x2308d0f24 0x230c012b0 0x206f275d8 0x102fecc78 0x102ff0840 0x206f61040 0x206f60cdc 0x206f61294 0x20453c728 0x20453c6a8 0x20453bf90 0x204536ecc 0x2045367c0 0x20673779c 0x231007c38 0x102c076d0 0x203ffa8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The problem is this:
ViewController *rootViewController = (ViewController *)[self.window rootViewController];
But you have stated that the root view controller is a UINavigationController. You need to get your ViewController from the nav controller.
UINavigationController *rootViewController = (UINavigationController *)self.window.rootViewController;
ViewController *viewController = (ViewController *)rootViewController.topViewController;
Then update the rest of the code to work on viewController.
Terminating app due to uncaught exception 'NSInvalidArgumentException', > reason: '-[UIViewController setDicSelectListItem:]: unrecognized selector sent to instance 0x10981be30'
I tried comment parameter passing. also tried provide main storyboard.
Below is the code where app getting crash
BilingInfoVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"BilingInfoVC"];
vc.dicSelectListItem=_dicSelectListItem;
vc.serviceType=_serviceType;
vc.arrSelect_Addons = [arrTemp mutableCopy];
[self.navigationController pushViewController:vc animated:YES];
I want to pass parameters with instantiate view controller.
Check this:
Is vc really of class 'BilingInfoVC'? If you didn't assign it correctly in IB it's a standard view controller.
You may check it with
NSLog(#"Class: %#", [vc className]);
As second line right after instantination of vc.
Did you set the identifier correctly? A capital letter can make a difference!
I am develop a sample app with multiple xib files and trying to make a navigate, first view to second unfortunately app has crashed
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewController'
What is the reason? some code that I used:
#import "ViewController.h" /*current view*/
#import "secondViewController.h" /*view for navigate*/
-(void)navigation{
secondViewController *desController=[[secondViewController alloc]initWithNibName:#"ViewController" bundle:nil];
[self presentViewController:desController animated:YES completion:nil];
}
i think you pass wrong name in initWithNibName:#"ViewController" that cause the error.
According to crash log, problem with nib name. Instead oneViewControllerl, nib name may be oneViewController. Check with nib(xib) file & Fixed correct nib name.
Cross check if you are setting correct Nib name instead of ViewController?
secondViewController *desController=[[secondViewController alloc]initWithNibName:#"ViewController" bundle:nil];
I am new in ios development i know pretty simple , i want to change view on button click
this is my code i create Tabbed Application ,storyboard flow is
TabView Controller-> Navigation Controller
->HomeViewController->Navigation Controller->ShopViewController
Code snippet:
#implementation HomeViewController
#synthesize users;
- (IBAction)shopButton:(id)sender {
NSLog(#"hi sachin");
NSLog(#"INSIDE Shops");
ShopViewController *cvc = [[ShopViewController alloc]initWithNibName:#"ShopViewController" bundle:nil];
[self.navigationController pushViewController:cvc animated:YES];
}
Its showing an error like this:
Pacific1[2556:70b] hi sachin
2014-02-25 16:34:49.374 Pacific1[2556:70b] INSIDE Shops
2014-02-25 16:34:49.632 Pacific1[2556:70b] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Could not load
NIB in bundle: 'NSBundle (loaded)' with name 'ShopViewController''
If you are using a storyboard, you should instantiate your view controller using the instantiateViewControllerWithIdentifier method.
Example:
ShopViewController *viewController = [[UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:#"ShopViewController"];
Make sure that the identifier is correct. It's under the Identity Inspector tab in Interface Builder. It's called Storyboard ID. You can give it any unique name that you want. Also make sure that story board name matches the name of your storyboard (without file extension).
Then:
[self.navigationController pushViewController:viewController animated:YES];
Your "ShopViewController" xib does not exists. See:
Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Could not load
NIB in bundle: 'NSBundle (loaded)' with name 'ShopViewController''
"Could not load
NIB in bundle"
If you're using storyboards you may want to instantiate the view like this:
ShopViewController *cvc = [[UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:#"ShopViewController"];
Not 100% on that, but someone else may be able to point you in the right direction as I don't use storyboards.
ShopViewController *cvc = [[UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:#"youstoryboardID"];
If still it,s not navigating than in story board select MainViewcontroller and click on Editor>Embed In in that select NavigationController.
I think it will work.
I have a segment control in a viewcontroller (UISegmentController.h, UISegmentController.m, UISegmentController.xib) created in a xib. Now I am trying to segue (ideally push) to Storyboard viewcontroller (ChartviewController.h, ChartviewController.m) I created. This Viewcontroller will hold images. I tried to perform this push as below:
-(IBAction) segmentedControlIndexChanged;
{
//some code
ChartViewController *chartviewpage = [[ChartViewController alloc] initWithNibName:#"ChartViewController" bundle:nil];
[self.navigationController pushViewController:chartviewpage animated:YES];
//some code
}
I used to implement this code to another xib viewcontroller and it worked fine. But now not with the stroryboard viewcontroller.
However, I receive an exception as follows:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ChartViewController''
* First throw call stack:
(0x15e6012 0x11b3e7e 0x15e5deb 0x53ffac 0x404e37 0x405418 0x405648 0x405882 0x405b2a 0x41cef5 0x41cfdb 0x41d286 0x41d381 0x41deab 0x41e4a3 0x41e098 0x4048 0x11c7705 0x327920 0x3278b8 0x3e8671 0x3e8bcf 0x3e86a6 0x43d597 0x43f83b 0x35716d 0x357552 0x3353aa 0x326cf8 0x22d1df9 0x22d1ad0 0x155bbf5 0x155b962 0x158cbb6 0x158bf44 0x158be1b 0x22d07e3 0x22d0668 0x32465c 0x1d0d 0x1c35)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Can u help please?
Thanks very much!
I finally figured it out doing a bit more research. first, one needs to instantiate the controller (ChartViewcontroller) in the storyboard they are trying to transition to. Then you need to give a storyboard ID name (ChartID) to the controller which can be find under the file inspector after selecting the controller. Finally perform the push to the new controller.
Hope this helps someone.
UIStoryboard * myStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
ChartViewController *chartpage = [myStoryboard instantiateViewControllerWithIdentifier:#"ChartID"];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:chartpage animated:YES];