UIStoryboard *storyboard = self.navigationController.storyboard;
DetailTrickEnter *viewController = [storyboard instantiateViewControllerWithIdentifier:#"DetailTrickEnter"];
[self.navigationController pushViewController:viewController animated:YES];
'Storyboard () doesn't contain a view controller with identifier 'DetailTrickEnter''
In the storyboard there is a viewcontroller with name I checked it very precisely.
Help with it.thanks
The reason is because you are supposed to go to the storyboard and then select your view controller and on the right go to the tab that says storyboard ID and type: DetailTrickEnter
Set Storyboard identifier Storyboard ID: DetailTrickEnter
Related
I'm writting my first app using a storyboard. Before I had the following code to go from one view controller to another. But..this code needs a NibName. How would I do this going from screens created in a storyboard?
if (mDisplayCard==nil)
{
mDisplayCard = [[cDisplayCard alloc]
initWithNibName:#"cDisplayCard"
bundle:[NSBundle mainBundle]];
}
// [ mDisplay SetUp];
[self.navigationController pushViewController: mDisplayCard animated:YES];
A line like the following will instantiate a new view controller from a storyboard:
UIViewController *newViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"<identifier-from-storyboard>"];
It is assumed that your current view controller was instantiated from the same storyboard, so that self.storyboard is not nil. For the view controller that you want to instantiate, you'll have to make sure that you set a storyboard ID for it, which is what you'll put in for the identifier.
I have started an iOS app with storyboard. In my app, mainStoryBoard starts with navigation controller. From navigation's view controller, I pass the controller to a second viewcontroller with a push segue by programatically ([self performSegueWithIdentifier:#"currencyClick" sender:self]). On the second view controller I have a button. On button click I want to go back to navigation's viewcontroller like [self.navigationController popViewControllerAnimated:YES] but here self.navigationController popViewControllerAnimated:YES is not working . In my project I unticked Shows navigation Bar in Navigationcontroller.
NavigationController-(root viewcontroller)-> viewController --(push segue with [self performSegueWithIdentifier:#"currencyClick" sender:self];)-->CurrencyViewcontroller
In currencyviewController I have a button. On button click I want to implement navigation back button click event. How do I implement a BACK Button programmatically, [self.navigationController popViewControllerAnimated:YES] is not working in this case.
Please help me to solve this problem..
Thanks in advance
to call secondcontroller in your first view controller use:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"mainStoryBoard" bundle: nil];
SecondViewController *rvc = (SecondViewController *)[storyboard instantiateViewControllerWithIdentifier:#"SecondViewControllerNameInYourStoryBoard"];
[self.navigationController pushViewController:rvc animated:YES ];
instead of self performSegue... Then in your second controller pop should work.
I'm trying to push a UIViewController on to my navigation stack using the following:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle: nil];
TestViewController *lvc = (TestViewController *)[storyboard instantiateViewControllerWithIdentifier:#"TestViewController"];
[self.navigationController pushViewController:lvc animated:YES];
TestViewController has a scene in the storyboard and ViewDidLoad is always called BUT if I trigger this code with a button click I get a blank view added the the navigation stack. It has a navigation header and back button. If I click the back button, the calling view is also blank.
If I call this code in the ViewDidLoad of my calling UIViewController it works as expected and I can see the view from the storyboard. The back button then works fine.
Could my original view be getting deallocated?
Thanks very much
I have an iPhone master-detail storyboard app which uses two differ detail view Controllers (a create VC and an edit VC). From the master view, if I hit the "+" new button I segue programmatically to the create VC while if I choose a tableViewCell the program segues to the edit VC. All that is working just peachy. Now I want to be able to segue directly from the create VC to the edit VC. Problem is I end up with the exception 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
My storyboard looks like this.
I've also tried embedding my detail VCs in navigation VCs without success.
Also, keep in mind that I'm trying to go from a stack of
master->createDetail
directly to
master->editDetail
not
master->createDetail->editDetail.
I really just want to pop off the createDetail and replace it with an editDetail.
Suppose there are 2 parameters to send on next view as CustomerName and Email then code will be :
-(IBAction)btnNextViewClicked:(id)sender
{
UIStoryboard * myStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle:nil];
NextViewController * nextView = [myStoryboard instantiateViewControllerWithIdentifier:#"nextViewCNTR"];
nextView.validEmail = #"abc#gmail.com";
nextView.customerName = #"ABC";
[self.navigationController nextView animated:YES];
}
If U dont have parameter then :
-(IBAction)btnNextViewClicked:(id)sender
{
UIStoryboard * myStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle:nil];
NextViewController * nextView = [myStoryboard instantiateViewControllerWithIdentifier:#"nextViewCNTR"];
[self.navigationController nextView animated:YES];
}
nextViewCNTR is name of indentifier to put on flow line while desingning in XCode.
Use and let me know feedback.
use a UIContainerView in your detailview
First, I am using storyboards for my navigation. I have come to a point where I am at a menu screen that goes off to 4 different views (just with a navigation controller) for 2 of those views I want it to check if the user has logged in and if not I want the LoginViewController/View brought up. I am very new to objective c/xcode and after searching for a solution this is what i have come up with. I do not know how to tie this in to my program. Does this just need to be linked to my button or am i completely off with what i am doing now?
if (self.appDelegate.userHasActiveLogin) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:#"ViewController2"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:vc animated:YES];}
else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:#"LoginController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:vc animated:YES];
}
What you could do is to create manual segues in your storyboard.
Ctrl-drag from your menu controller (orange symbol) to the child controller, select push. Click on the segue and give it an identifier in the attributes inspector. Now you can check if user is logged in and then conditionally call [self performSegueWithIdentifier:#"logged in segue" sender:self]; in your menu's VC.
The condition is that all the VCs must be in the same storyboard, but I suspect that is the case.