iOS - navigation controller back button - ios

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.

Related

Tabbar Controller to ViewController with backbutton

I have a tabbar controller implemented in my app, when i am fetching newsletter from server i have added a view controller in which i am showing the posts against that new'sletter the issue is i want the view controller back button so that user's can go back to tabbar controller. Below is the attached image of my issue,
I DON'T WANT TO EMBED NAVIGATION CONTROLLER.
if you don't want to embed navigation controller,you may try to modal a view controller.and dismissController you view Controller back to tabor 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;
}];

Dismissing a modal view controller via code

iPhone project/iOS 7.1/objective-C Due to circumstances, i have presented a navigation controller which contains a view controller which in turn contains a web view.All of the before said are added programmatically (i.e. no .h,.m or xib files).How do i dismiss the navigation controller?
P.S: I've created all these in a method.There is no property or instance available for the navigationcontroller.
you have to create on barButtonItem on navigation bar like "Back" or "Done" and on it's click event you should write :
[self dismissViewControllerAnimated:YES completion:nil];

Dismissing a modal view and pushing to a uinavigation controller through delegation [duplicate]

I have a tab view controller with a navigation controller. In the first tab item I click on a button in a view that pops up a view with animated: YES.
Then when that view is done I hit another button that dismisses it. Like:
[self dismissViewControllerAnimated:NO completion:^{
ProfilesViewController *profile = [[ProfilesViewController alloc] init];
[self.navigationController pushViewController:profile animated:YES];
//SHOW YOUR NEW VIEW CONTROLLER HERE!
}];
But everytime this code runs, it dismisses the view, DOES NOT push the profiles controller, and shows the view from the first tab bar item.
How do I push the ProfilesViewController to the screen with a Back arrow?
If you are using dismissViewControllerAnimated to dismiss that means that the VC is presented modally. As such, it doesn't have a navigation controller (so self.navigationController is nil) and thus it can't push anything into the navigation controller.
You should really add a property to the controller which is a delegate or a completion block which can be used to push the controller from another controller (the one that presents it) to dismiss and push the controller.
A second option is to pass the navigation controller, it's a similar amount of code to using a block but not so good.
A crappy option is to use the parentViewController to find the appropriate navigation controller, but that sucks for many reasons.

Dismiss Modal NavigationController from pushed ViewController inside

I have an iPad app and I'm using the storyboard. I'm presenting a modal view, which I wrap in a UINavigationController. It's a modal "Settings" view with it's own navigation.
I have a delegate setup to dismiss the modal view itself with a Done button in the Settings view which works fine, but I need to be able to dismiss it even after it has pushed another view when the user taps a setting.
So, basically a "cancel" button on the right side of the Navigation bar in the pushed views.
Instead of having to go back to the first "Settings" view to hit the done button.
I've tried setting up a second delegate for the pushed view without success:
Just add a bar button item and put this line in its action method:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
The presenting view controller will be the controller that presented the modal, not the navigation controller.

Resources