Connecting two storyboards - ios

I have two different storyboards named "MainStoryboard" and "TPStoryboard". In TPStoryboard, I have set CCViewController as my initial view controller (names are changed here).
In MainStoryBoard, I have a tableView, and when user selects a cell, he is expected to land in the initial view controller of TPStoryboard. The following is the code I have written:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *stb = [UIStoryboard storyboardWithName:#"TPStoryboard" bundle:nil];
CCViewController *ccv = [stb instantiateInitialViewController];
[self.navigationController pushViewController:ccv animated:YES];
}
This gives the exception
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'TPStoryboard' in bundle NSBundle"

The error states that there's not such file in the bundle, so it's very likely that you are either misspelling the name or that the storyboard file is not included in the target.

Related

Move to next view controller, i am using storyboard

Here is my code
RadarViewController *wc = [[RadarViewController alloc]
initWithNibName:#"RadarViewController"
bundle:nil];
[self.navigationController pushViewController:wc animated:YES];
Here is the error comes after crashing the app.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-10-14 12:25:02.596 Quick man help[890:60170] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/brainpulse/Library/Developer/CoreSimulator/Devices/0FD1A490-11AF-468D-96D3-71F37DDD8552/data/Containers/Bundle/Application/35FDBB50-E294-458B-B367-A57E3FC0B594/Quick man help.app> (loaded)' with name 'RadarViewController''
Your Xcode can not find a xib with name "RadarViewController" because you are using storyboard ....
You need to create instance of RadarViewController from storyboard like
UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
radarVC = [mystoryboard instantiateViewControllerWithIdentifier:#"radarVCID"];
You need to set radarVCID as storyboardID of RadarViewController in your storyboard
It seems that not all connections as parts of the archive has been already loaded from the storyboard at the moment you call initWithNibName as same as instantiateViewControllerWithIdentifier.
I suggest you to instatiate your view controller in viewDidLoad.
If it won't help, try to look if your storyboard is correct. To achieve this open it as a source code and look at opening/closing tags
After all of that, delete you view controller and re-add.Don't forget to create a copy of your storyboard before performing all of this.
Do something like below:
Select your RadarViewController in storyboard
In Identity Inspector, give RadarViewController identifier in Storyboard ID. for example "capture" as you can see in screenshot
Now write something like below:
RadarViewController *obj = [self.storyboard instantiateViewControllerWithIdentifier:#"youridentifier"];//youridentifier =capture as per screenshot. You can give whatever identifier to `RadarViewController`
[self.navigationController pushViewController:obj animated:YES];

push view controller by search button

i have Storyboard with UINavigationController i have created the first screen with searchbar
i have added second viewcontrol via IB to storyboard
how do i push the second viewcontroller to navigationcontroller ?
i have tried
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
ViewController *screen2 = [[ViewController alloc] initWithNibName:#"ViewController2" bundle:nil];
[self.navigationController pushViewController:screen2 animated:YES];
}
i have set Custom Class of second view controller to ViewController2
but when i run the app and click the search button in keyboard i get the following error
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewController2''
The error you are getting is because Xcode cannot find the xib named ViewController2.
You may just call self.performSegueWithIdentifier(#"identifierToViewController")
But first make sure that your searchViewController is a child of an UINavigationController
Then make sure that the segue has a proper identifier:
First of all make sure that your second view controller class name is : ViewController2
After that in storyboard give your View Controller's class name and Storyboard Id as #"ViewController2", Please refer screen shot.
Actually you use wrong method to create instance of UIViewController as it is used when you use xib file.
Change your code like this :
ViewController2 *screen2 = [self.storyboard instantiateViewControllerWithIdentifier:#"ViewController2"];
[self.navigationController pushViewController:screen2 animated:YES];

error "has no segue with identifier" adding split ViewController

I'm adding a split ViewController with the table view and detail view:
The tableview works fine the cell are been populated and everything but when one of the cells is been selected I get the error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<masterViewController: 0x15ce0e9b0>) has no segue with identifier 'detailView''
Here is my code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"detailView" sender:[_arrayOfFiles objectAtIndex:indexPath.row]];
}
Here is the info of the detailView:
I add identifier to the storyboard segue:
but now I'm getting the following error:
* Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'show tableVIew'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
* First throw call stack:
You need to set the identifier for the segue, not the viewController. If you click on the line joining the two viewControllers, you can then set the attributes for the segue in the attributes inspector:
If I'm not wrong you should be adding a Navigation Controller to bot the Master and Detail View Controllers.
Additionally, for a split controller to function it must be set as the root controller.
Good luck!

ios change view on button click

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.

Segue from segmentcontrol in XIB Viewcontroller to Storyboard Viewcontroller

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];

Resources