I'm trying to jump to a View that's on another Navigation Controller.
You Can see the situation from my storyboard:
Once I get to the the "Edit Sticker" view i want to go back to the "Create Pack" but I don't want that the "back" that I get once i click save takes me back to "Edit Sticker", it should take me to the view that's on the left of "Create pack".
You can see the situation from this:
What could be a good solution?
How can I invoke a segue (the first one you see on the first picture on the top left, that's calling "Create pack") that's on another Navigation view controller?
UPDATE:
Tried setting it with one Navigation Controller:
and programmatically setting this when I press Add:
self.navigationController?.popToRootViewControllerAnimated(true)
takes me back to the "1st View". I need to go the "Create pack" view.
How come the Edit Sticker view controller is on its on navigation controller?
If the navigation hierarchy went Root -> Create Sticker -> Edit Sticker, you can call self.navigationController.popToRootViewController when the user clicks save.
But if you want to control the segue, then use self.navigationController.popViewControllerAnimated(animated: Bool) as that just pops the view on top to give you more control.
Related
I have a 'main menu' view controller with links to different types of calculators. When I click on the link to a new calculator, the "main menu" can still be seen behind the new page. I would like to have the calculator completely replace the main menu when I click the link. I've tried modifying the segue on the storyboard, but cannot figure out how to fix this.
Storyboard settings
Purple outlines the main menu hiding behind the new view controller. I want this to go away.
You will need to embed the "Main Menu" into a Navigation Controller. If you don't do this, no matter what type of segue (which you refer to as a "link") you use, that outline will always be visible. To do this, select the Main Menu View controller from the storyboard, and click a little button on the bottom right of the screen looking like this:
and select "Navigation Controller".
Next, you can do one of the following:
Click on each segue from the main menu to each type of calculator, and in the attributes inspector, change the "Kind" (Which you currently have as "Present as Popover" to "Show".
Alternatively, if you like the way the segue slides up, and would just like it to be full screen,change the "Kind" setting to "Present Modally", and change the "Presentation" setting (under "Kind") to "Full Screen", for as many of the segues as you'd like.
thanks in advance
here is the image which will help you understanding my problem
there is menu button where "Back" is written.
i want to implement slide menu on RecordsVC. tableViewController will be sliding menu, slide menu will contain EditContact, Download Records, Settings.. what should be the exact navigation flow. where should i push segue from RecordsVC... i know where to set "sw_rear" segue and "sw_front" segue from SWRevealViewController.. m just asking where to push the segue after RecordVC...
how to connect RecordVC and SWRevealViewController
update and Download are buttons which takes to addUpdateVC and DownloadVC simultaneously.
enter image description here
i hope i would be clear this time.
take a look at image what should i do
If i understand correctly you are trying to go from Menu to View Controller so you have to create a new segue from Menu View Controller (TableViewController) to View Controller whatever you want then click on segue then go to "Attributes" section set the Segue Class to "SWRevealViewControllerSeguePushController":
Then on Menu View controller call
performSegue(withIdentifier: "goToFavorites", sender: item)
If you want to go a View Controller directly from front view controller use this code:
let vc = MyViewController() // init this from storyboard
self.revealViewController().setFront(vc, animated: true)
I'm trying to create a back button on my navigation bar in x code. However when I drag it across from the objects library to the navigation bar in the storyboard it doesn't come up.
OK So this is crazy but...
Click on the navigation bar and in the attributes inspector, Just Type something in the field marked Back Button. Then in the scene hierarchy you'll see the button, though it won't yet appear on your navbar. In the hierarchy, drag the button onto the Navigation Item and viola it appears. Now to make second one, hold option and copy the first one. If you try to add one from the object browser, you'll lose the first one.
If done properly, the first will show up on the right and the second on the left.
Good luck.
This happens when the navigation is not set up correctly, as dbajkovic mentioned, if you do not have a navigationcontroller, it will not work. Your scoreboard should look like this:
You can not add the button to the left, only to the right.
#Jonathan Thompson: I came across your post and since I just learnt something new, I am going to add it as a response to your question.
There are two separate buttons - Back button and Bar Button. Back button has a reverse (right to left) pointing arrow and a Bar button is a regular rectangular button. The following describes how your could implement them in your program:
Back button:
On the root view controller, ctrl + click on button and drag it to the view controller you are trying to connect it to. When you are given an option to select from, choose Push, not modal. This will automatically add a back button on the next view controller. (Run the program to confirm it.)
Bar Button: (Credit: dbrajkovic)
For adding the bar button, click on navigation bar of the navigationViewController you are interested in. Under Attributes inspector, type some name in Back Button and hit enter to confirm. Open document outline and locate the viewController you were working on. On the left side of Navigation Item locate the disclosure triangle. Click on the Bar Button Item. Ctrl + click + drag the button to the navigation bar of that viewController. You can choose whether to place it on the left / right side.
I have a navigation bar in my app. The below pictures are in the order of navigation.
Problem I have is, on clicking the "Main" button , I am able to perform the action and goto the required screen , but the navigation bar does not look like the first on (with Menu as left button). Instead it look like 4th image. How to make it look like first image so that I can make the user to navigate to "Menu" screen by clicking menu button ?. Thanks for the help …!!!
If I'm understanding this correctly, you may have pushed the first view controller (The one from screenshot 1) when clicking on main which is why you see "lens" in the back button. That back button takes the title of the previous view controller in the stack. What you want to do is pop to the first view controller when they click on Main using either popToRootViewController or popToViewController:animated
Just want to confirm this, as I'm trying to learn monoTouch alone..
I have a view which I navigate to using NavigationController.PushViewToController(). On the destination view, I have a Navigation Bar. I can add a button to the bar and use code to push to another view (I happen to know where Back is), fine.
Is there a existing "back button" control? Or a way in to code to change the existing back button to say "Go back"?
In Interface Builder I can see there is a property on the navigationItem called "Back". When I add text to this I can see a new BarButtonItem added to the navigationBar. However I never see this button when I navigate to the view in the simulator. If I try to drag the item onto the view manually, the "Back" text is cleared and the button is treated like a custom button.
Do I always have to manually code the back button?
The default back button (the one that takes the name of the previous controller) cannot be customized. But you can hide it and replace that button with a new one.
If you have a controller, you can do that on the viewDidLoad method. Overriding this method you are sure that all the elements have been set.
// allows you to hide the back button
NavigationItem.SetHidesBackButton(true,true);
// allows you to create a new customized button
NavigationItem.LeftBarButtonItem = new UIBarButtonItem(...);
UIBarButtonItem takes an handler that you can use to control the navigation.
In the handler you can do this:
NavigationController. PopViewControllerAnimated(true);