Brief Explanation:
View 1(Navigation Controlled) has a "add new object" button A.
When click button A, it will move to View 2 (Navigation controlled and has back to view 1 button on the top with "< View 1")
View 2 has a "Save object" button B, which I will add a new object into View 1's NSMutableArray.
However, when I click button B, it will go to View 1 with "< View 2" back button on the top of navigation bar even though it's the root navigation view.
On storyboard, button A and B action is as push.
Question
How can I get out of this navigation movement?
Is there a way I can direct to button B action to a certain view? Without navigation back bar automatically added on top?
The action for button B shouldn't be a push since you want to go back to the first controller. When you want to go back to the previous controller, you either should use the default back button in the navigation bar, or if you have a custom button, you should have popViewControllerAnimated: as its action.
Related
I have 4 tabs and in the home tab, I have a button to goto profile view controller.
When I use segue, The view changes completely and it's presented over tab bar. So it gets hidden.
I want to present it under the tab bar so that I can quickly navigate to other tabs without a back button.
I am not sure if this is the right way or not. but you can add presenting viewcontroller's view as subview with the same animation.
I'm working with the Xcode view editor and Swift.
I have my main view which contains a tab bar controller with 2 tabs.
On the second tab, I have a #IBoutlet var myLabel: UITextLabel!. Inside viewWillAppear I put some text in this label.
On the first tab, I have a button which launch a third view through a Push segue, and on this new tab, I have a Back button which gets me back to the main view containing a tab bar controller (through a push segue too).
When I launch my app, go in my second tab, the text of the UITextLabel is changed.
I still can go to my first tab and navigate between them it works.
But the problem is when I click on my first tab's button, then on Cancel, then goes back to my second tab, my UITextLabel doesn't change. And I can't perform any action on it anymore. It's not nil though but it's like it's still connected to the first UITextLabel before the segue and not this one.
Where am I wrong ?
Several things are wrong.
With tabbed apps, Apple says that the tab bar controller should be the root level navigation method for the app. It should always be present, and the user should always be able to tap another tap to switch to another part of the app.
So the first tab should connect to a navigation controller. When the user pushes the button, you should push a new view controller onto that navigation controller. The tab bar will still be visible and enabled, and the user will still be able to switch to view controller one.
Next thing:
You say "I have a Back button which gets me back to the main view containing a tab bar controller (through a push segue too)."
That's very wrong. Back buttons should pop a view off of the current navigation stack. They should not be pushing anything. Any time you use a push segue, you are creating and pushing a brand new instance of a view controller, and leaving the other view controllers in the navigation stack.
I have 2 UIViewControllers with their own navigation bars, but they're not embedded in a Navigation Controller. I want the bar button item of the first view to push the second view, and a bar button on the second view to pop the view, showing the first view underneath.
I've added a show segue from the first view to the second one in my storyboard but I can't find a pop segue when I try add a segue between the second view's bar button back to the first view. Here's what my storyboard looks like:
How would I make the back button on the second view pop itself to show the first view?
I am working in a swift 3 xcode 8 project, and I have an issue.
I have some view controllers.
In the first one I've inserted a navigation controller, which gives me the "back" button when I am in another view controller. So I can go on and back to the first viewcontroller.
The thing is, lets say, when I am in the third view controller I'd like to insert a button, but appearing just in this viewcontroller in the navigation controller.
I've tried adding a bar button item but it doesnt work because the navigation controller only appears, in the storyboard, in my first viewcontroller.
So how can I add buttons to the navigation controller, in another viewcontrollerS?
So how can I add buttons to the navigation controller, in another viewcontrollerS
Drag a Navigation Item into your third view controller. Now you can add bar button items to that.
I am very new to Xcode and have encountered an issue with my app. I am trying to create a tab bar app. On one of the tabs I have a button that brings the user to a different ViewController. I want to have it so the user can select a button that would return them to the tab that had the button. I tried to set up an action from the button to the previous view (the tabbed screen), however the tab bar disappears. I hope this is makes sense.
Here is a link to a screenshot...
Easiest way to do this is to place a UINavigationController as the root view controller of the TabBarController. You can do this in storyboard by simply ctrl+dragging from the tabbar controller to the navigation controller and adding it as a relationship.
Here's an example using storyboards:
The next step is to set the third controller (in this case the table view controller) to your player view controller class.
Then, you can use the default back button and animation that comes with the navigation controller. If you prefer to hide the navigation bar at the top of the screen, then you can use your custom back button to call
[self.navigationController popViewControllerAnimated:YES];
You can also choose custom animations / segues, etc. but using a navigation controller to help you navigate screens is probably the simplest approach.