How to transition to root view controller without navigationController? - ios

I have an application that transitions from the main launchVC to a register or login VC and then from there transitions into the main application view controller. Now I am not using the built in navigation that you can use with an iOS app instead I'm using my own buttons. So my question is how do I "pop back" to the launchVC. Image in application where you have logged in and when you tap "log out" all of the view controller get dismissed back to the launch view controller. Any help would be appreciated. Thank you!

You can make your launch view controller a delegate, passing it to the view controller that contains the logout button. Once the button is pressed, then that will notify the delegate (launch view controller) which can then dismiss all of the presented view controllers.
Here is a tutorial on how to configure such a pattern.

Related

iOS Swift - Using temporary UIView that can be cancelled

I have a View Controller that is attached to a Navigation Controller (so any segue out of the View Controller maintains the view hierarchy of the Navigation Controller). How would I go about creating a temporary view that pops up from below that can be cancelled and does not conform to the Navigation Controller. For example, the 'Add Event' button in the Apple Calendar App, which brings up a screen that can be cancelled and brought back down.
You can use a UIPopoverController or you can just make a custom UIViewController and add it to the current view controller as a child view controller and present it modally without interfering with the Navigation controller.

warning attempt to dismiss from view controller while a presentation or dismiss is in progress

Steps to reproduce -
Open Modal view controller on tap of button of Root View controller.
In Modal view controller - On button, create segue to show popover view controller.
Tap on button to see Popover view controller.
Now multiple taps on screen to dismiss the popover view controller, it directly redirects to Rootview controller.(dismissing the Modal view controller).
Another approach -
Create IBAction to show popover view controller.
Tap on button to see Popover view controller.
This time it just dismiss the pop view controller. (Not redirecting to RootView controller)
Why this weird behavior when your showing Popover view controller in two different ways?
I am working on already developed big project and now its not possible for me to go ahead with second approach.
Please help me to find out the better way to resolve this.
You will need to create a delegate method in your Modal view controller.
After your popover view controller dismissed, then call your Modal view controller delegate method to dismiss as well.
[self dismissViewControllerAnimated:YES completion:^{
ModalViewControllerDelegate.dismissView;
}];

Dissmiss modal controller triggered Segue in Swift/Objc hybrid project

I have a situation that I'm not sure how to handle correctly. As you see in the picture below I have a Table View Controller, I have a Modal Popup and another View Controller.
What I'm trying to do is when the user clicks a button on the left most TableView controller a pop up will display via a Modal Segue. Once dismissed the the Navigation Controller will transfer to the Right ViewController
Initial View Controller
* Button Pressed Segue Modal
Swift Modal Controller
* Presses button and calls self.dismissViewControlelr
But then what happens?
If I understand correctly, you'd like to have the navigation controller perform a push segue after a presented view controller dismisses itself.
There are a couple ways to go about it, but I think simplest is to have the presented view controller (the "swift modal") post a notification from within the completion block of the dismiss function.
The vc contained by the navigation controller should then perform the push segue upon receiving this notification.

iOS - navigation controller back button

I'm developing an iPad App using storyboards. In this app when the user click on "preferences" appear a modal View. One button of this view send the user to another View Controller (but this view has an action bar to go back to his root view controller), but when user taps the action bar back button nothing happen (it's called navigationController popViewControllerAnimated), the user continue in the same view.
Can anyone help me??
Thanks.
UPDATE:
The code to handle the back button:
- (IBAction)btnBackTapped:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
I'm using Segue (from storyboard) to call this View Controller:
When the user click on "Meus Favoritos"
They will be redirect to this page:
The segue is with a Modal (from image one to two)...
When you are presenting a View Controller modally, it is likely not within a Navigation Controller, so probably the reference to navigationController in your code is nil, can you check that?
If you are presenting your View Controller modally this will work instead
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
However, if you actually want to use a Navigation Controller, you should embed the View Controller that is presenting the Preferences View Controller in a Navigation Controller and present the Preferences View Controller with a show segue instead of a modal one.

Presenting modal view over partial page curl modal view

I have my main menu embedded in a navigation controller. The settings button performs a modal segue to show my settings page which is half a page shown using the partial page curl.
Now on the settings I have a 'legal' button which I want to just display a full screen UITextView with all my legal stuff.
The problem is, when I display the legal view controller using a modal segue, it displays behind the partial page curl.
If I try using a push segue, it crashes because there is no Navigation controller as the settings is shown modally.
Is there a way to present a modal view over the top of a partial page curl?
Thanks
Best option I can think of is managing all your segues in your initial main menu controller.
For example, you can write a delegate method such that, if the user hits 'legal', you dismiss the modal view (from within your main menu controller's .m) using a delegate method, and then in that same method present a new modal view controller for the settings page (with it's parent being the main menu view controller, which can then have another delegate method to dismiss the legal page and present the settings menu).

Resources