iOS move to segue without adding ViewController to stack - ios

In my application i'm using the navigation controller as an "Action Bar" and in most scenarios there is no Back Icon.
If i understand correctly, when i'm using segues to move to the next screen, iOS keep a reference of my last screen so i will be able to press back and return to it quickly.
can i have the same segue with moving to next screen, but somehow tell the navigation bar not to save an instance of the the last view controller ? i need that in order to avoid duplicate view controllers in the view controllers stack, and to avoid overloading the memory.

Related

dismiss a tabbed view controller from a seperate modaled to view controller

So, I have a tab bar view controller, however at some point I need to manually segue to a viewcontroller that is not attached to the tab-view controller. The segue works, but then it jumps back again to the previous view controller randomly after 1/2 a second to 3 seconds, not all the time, but often. Occasionally I see a message saying something along the lines of "cannot dismiss viewcontroller while another dismiss or presentation is already taking place" but I've double checked all my code and there are only three places that make the jump, none of which can be called simultaneously. What I need to know then, is how I go about dismissing the tab viewcontroller in the view did load method of the modaled to controller. Swift explanations are no good to me thanks. Also, not related to this question persay, but can anyone tell me what the sliding bar thing that looks like a UISlider and tracks the progress of a song is called?

I need some clarity on Navigation Controllers

I have a total of 3 views. A menu, the main view where the action happens, and a settings menu.
You can access the settings from both the menu and the main view and go back using the back button provided by the Navigation Controller.
In the main view I have hidden the NavigationBar to free some space, and there's a specific button to go back to the menu. From what I know and have read, I assume this just adds more and more views to the Navigation Stack if I keep going from the main view to the menu again and again, creating a lot of views in the stack.
I'd like someone to tell me whether my assumption is true or not, and evt. explain me the whole process behind navigating and views.
UINavigationController has a property viewControllers which is the stack of view controllers that have been pushed there.
If you use push segues in your storyboard each time you trigger this segues you push the current controller to the stack.
If you have a special logic I suggest you manage controllers programmatically.
This might clear it all.
There are basically following types of Segues to navigate to any viewController
Show (Push)
Show Detail (Replace)
Present Modally
Present as Popover
And to move back use Unwind Segue
You can read more regarding this here

Issue with increase memory usage when looping UIViewControllers using UINavigationController

I'm trying to loop through several UIViewControllers: where the 1st (start) view is a menu and the final view serves as the results page that loops back to the starting view, after clicking my bar button "Finish".
Testing with the storyboard, I of course use push segue to navigate through the views, but then employ a modal segue with the "Finish" button to bring me back to the starting view controller, which has the embedded navigation controller. This prevents me from using the back button to go past the starting view and undoing past loops. This is a good thing (took me a while to figure out), as I don't want to cycle farther back then the starting view of one loop.
My issue with what I have designed is my memory usage keeps growing, and I do not know how to deallocate/free the views from the previous loops. I plan to use arrays, images, tableViews within this application so I really need some guidance on how to free those large amounts of memory once the "Finish" button is pressed and the application segues to the starting menu view.
I'm using Xcode version 5.1.1. simulating iPhone 3.5-inch.
Thank you
You say:
... but then employ a modal segue with the "Finish" button
You do not want to to a modal segue with the finish button (because that keeps all the old view controllers in memory and instantiates a new copy of the first scene). If you don't dismiss all of those old view controllers, you'll end up "abandoning" the memory associated with those scenes.
Instead you want to use an unwind segue. This returns to a particular view controller, dismisses any intervening scenes (if any), and releases the memory associated with them and their view controllers.
In your first view controller, create a unwind action:
- (IBAction)unwindToFirstScene:(UIStoryboardSegue *)segue {
// this is intentionally blank
}
Having created that in the first view controller (the destination of the "finish" button), create a segue between the "finish" button in that last view controller to the exit outlet:
When you do that, you'll be prompted for the unwind action.

Data disappears when switching between view controllers

I am writing an iPhone application using the storyboards for an initial mockup. The problem I have right now is switching view controllers.
I have a table view controller and another view controller. All I want to do is use a back button to go back to the original screen, and I can do that, except the data disappears. The storyboard that I have is shown below.
I have the Back button going back to the original navigation controller. I have also had it going back to the Card view controller.
I have hard coded some example cells to just see how things look and they show up just fine when I run the simulation. When I click the back button though, it goes back to the All Cards screen and the cells that were there are now gone.
If I need to post some code just ask for what part would be helpful, I have done all of this through storyboards though.
I'm sure it's something stupid I've done, any point in the right direction would be greatly appreciated.
Basically: you pushed where you should have popped.
What you are seeing on the Storyboard does not exist yet. By segue-waying during runtime to a view controller it gets instantiated.
When you segue-wayed during runtime from the Add Card view controller "back" to the Card View Controller - here is what happened: instead of popping the navigation stack all the way back to the Card View Controller you already had, you just instantiated a new Card View Controller and pushed it onto the navigation stack. You could verify that by going all the way back to the original Card View Controller by tapping the back button several times.
What you could do to accomplish your task is this:
Instead of using the Storyboard for your back button use an IBAction in code:
- (IBAction)popToRoot:(id)sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}

iOS - NavigationBar Title overlapped by previous viewController

we have the issue, that if we pop back from a VC, the current ViewController's navigationBar title is overlapped by the just popped VC navBar title.
But it occurs only sometimes, so i assume it's maybe just a UI refresh bug. Did someone have this problem before, if yes.., how to fix it?
regards ..
I've run into this a few times in the app I maintain. In every case the problem was caused by people doing silly things with navigation controllers.
For example, when wishing to navigate to a new view, a view controller that was already part of a navigation controller's view stack would instantiate a new navigation controller and push its root view controller onto the first navigation controller's view stack.
Then, in the new view controller (the one contained in the second nav controller's view stack), they would try to pop to a previous view. This would cause funny animation bugs and random titles to show on the navigation bar.
The solution was to remove the second navigation controller from the flow (it didn't serve any particular purpose).

Resources