How to get back from tabbar view controller?
My Initial screen is HomeViewController
, from HomeViewController
I am move to TabBarViewController
. Now, I want to move back to HomeViewController
. I am using following code for that:
self.navigationController?.popViewController(animated: true)
But it's not working.
ios swift
add a comment |
My Initial screen is HomeViewController
, from HomeViewController
I am move to TabBarViewController
. Now, I want to move back to HomeViewController
. I am using following code for that:
self.navigationController?.popViewController(animated: true)
But it's not working.
ios swift
Can you show how you are addingtabBarController
fromHomeViewController
? Most probably you can doUIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
– Kamran
Nov 22 '18 at 6:58
I am using button for navigation from HomeViewController to Tabbar ViewController @Kamran
– MeMouli
Nov 22 '18 at 7:02
1
How are you moving from HomeViewController to Tab Controller? Are you using navigation controller to push your Tabbar ViewController?
– Natarajan
Nov 22 '18 at 7:08
Have you initialize your HomeViewController with NavigationController?
– hpp
Nov 22 '18 at 7:29
yes i initialize HomeViewController with NavigationController
– MeMouli
Nov 22 '18 at 9:46
add a comment |
My Initial screen is HomeViewController
, from HomeViewController
I am move to TabBarViewController
. Now, I want to move back to HomeViewController
. I am using following code for that:
self.navigationController?.popViewController(animated: true)
But it's not working.
ios swift
My Initial screen is HomeViewController
, from HomeViewController
I am move to TabBarViewController
. Now, I want to move back to HomeViewController
. I am using following code for that:
self.navigationController?.popViewController(animated: true)
But it's not working.
ios swift
ios swift
edited Nov 22 '18 at 8:03
John Kennedy
2,61321026
2,61321026
asked Nov 22 '18 at 6:56
MeMouliMeMouli
96
96
Can you show how you are addingtabBarController
fromHomeViewController
? Most probably you can doUIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
– Kamran
Nov 22 '18 at 6:58
I am using button for navigation from HomeViewController to Tabbar ViewController @Kamran
– MeMouli
Nov 22 '18 at 7:02
1
How are you moving from HomeViewController to Tab Controller? Are you using navigation controller to push your Tabbar ViewController?
– Natarajan
Nov 22 '18 at 7:08
Have you initialize your HomeViewController with NavigationController?
– hpp
Nov 22 '18 at 7:29
yes i initialize HomeViewController with NavigationController
– MeMouli
Nov 22 '18 at 9:46
add a comment |
Can you show how you are addingtabBarController
fromHomeViewController
? Most probably you can doUIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
– Kamran
Nov 22 '18 at 6:58
I am using button for navigation from HomeViewController to Tabbar ViewController @Kamran
– MeMouli
Nov 22 '18 at 7:02
1
How are you moving from HomeViewController to Tab Controller? Are you using navigation controller to push your Tabbar ViewController?
– Natarajan
Nov 22 '18 at 7:08
Have you initialize your HomeViewController with NavigationController?
– hpp
Nov 22 '18 at 7:29
yes i initialize HomeViewController with NavigationController
– MeMouli
Nov 22 '18 at 9:46
Can you show how you are adding
tabBarController
from HomeViewController
? Most probably you can do UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
– Kamran
Nov 22 '18 at 6:58
Can you show how you are adding
tabBarController
from HomeViewController
? Most probably you can do UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
– Kamran
Nov 22 '18 at 6:58
I am using button for navigation from HomeViewController to Tabbar ViewController @Kamran
– MeMouli
Nov 22 '18 at 7:02
I am using button for navigation from HomeViewController to Tabbar ViewController @Kamran
– MeMouli
Nov 22 '18 at 7:02
1
1
How are you moving from HomeViewController to Tab Controller? Are you using navigation controller to push your Tabbar ViewController?
– Natarajan
Nov 22 '18 at 7:08
How are you moving from HomeViewController to Tab Controller? Are you using navigation controller to push your Tabbar ViewController?
– Natarajan
Nov 22 '18 at 7:08
Have you initialize your HomeViewController with NavigationController?
– hpp
Nov 22 '18 at 7:29
Have you initialize your HomeViewController with NavigationController?
– hpp
Nov 22 '18 at 7:29
yes i initialize HomeViewController with NavigationController
– MeMouli
Nov 22 '18 at 9:46
yes i initialize HomeViewController with NavigationController
– MeMouli
Nov 22 '18 at 9:46
add a comment |
4 Answers
4
active
oldest
votes
Yah, It's not working, as well as navigationController?.popToRootViewController(animated: true)
not working so you can push to HomeViewController from TabBarViewController.
self.navigationController?.pushViewController(vc, animated: false)
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
add a comment |
How to get back from tabbar controller depends on how you got to it in the first plase.
If you pushed it into navigation stack, you need to call popViewController(animated:)
. This is clearly not your case.
You could've presented it modally. Then you need to dismiss(animated:, completion:)
.
If you set the tabbar controller as the window's root, then you need to reset the root with your HomeViewController
. E.g.
UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
add a comment |
You should custom a UITabBarViewController
When you want go to TabBarVC from Home, you push a navigation has root is a TabBarViewController.
At TabBarViewController, if you want to back to Home, call popToViewController method of nagicationVC.
Ex:
class HomeVC: UIViewController {
@IBAction func goToTabBarVC(_ sender: Any) {
let tabBar = TabBarVC()
let navigation = UINavigationController(rootViewController: tabBar)
navigationController?.pushViewController(navigation, animated: true)
}
}
class TabBarVC: UITabBarController {
@IBAction func backToHome(_ sender: Any) {
navigationController?.popViewController(animated: true)
}
}
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
add a comment |
In the app delegate file put following code in applicationDidFinishLaunching method.
let st = UIStoryboard(name: "Main", bundle: nil)
let homeVC = [st initializeViewControllerWithIdentifier:"HomeVC"]
let navigation = UINavigationController(rootViewController: homeVC)
self.window??.rootViewController = navigation
or
You can directly embed the Navigation controller to the home view controller from storyboard.
Thanks
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53425391%2fhow-to-get-back-from-tabbar-view-controller%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yah, It's not working, as well as navigationController?.popToRootViewController(animated: true)
not working so you can push to HomeViewController from TabBarViewController.
self.navigationController?.pushViewController(vc, animated: false)
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
add a comment |
Yah, It's not working, as well as navigationController?.popToRootViewController(animated: true)
not working so you can push to HomeViewController from TabBarViewController.
self.navigationController?.pushViewController(vc, animated: false)
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
add a comment |
Yah, It's not working, as well as navigationController?.popToRootViewController(animated: true)
not working so you can push to HomeViewController from TabBarViewController.
self.navigationController?.pushViewController(vc, animated: false)
Yah, It's not working, as well as navigationController?.popToRootViewController(animated: true)
not working so you can push to HomeViewController from TabBarViewController.
self.navigationController?.pushViewController(vc, animated: false)
answered Nov 22 '18 at 7:09
Haresh GediyaHaresh Gediya
265
265
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
add a comment |
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
It works, but navigation items are missing after i comeback from another view controller
– MeMouli
Nov 22 '18 at 7:54
add a comment |
How to get back from tabbar controller depends on how you got to it in the first plase.
If you pushed it into navigation stack, you need to call popViewController(animated:)
. This is clearly not your case.
You could've presented it modally. Then you need to dismiss(animated:, completion:)
.
If you set the tabbar controller as the window's root, then you need to reset the root with your HomeViewController
. E.g.
UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
add a comment |
How to get back from tabbar controller depends on how you got to it in the first plase.
If you pushed it into navigation stack, you need to call popViewController(animated:)
. This is clearly not your case.
You could've presented it modally. Then you need to dismiss(animated:, completion:)
.
If you set the tabbar controller as the window's root, then you need to reset the root with your HomeViewController
. E.g.
UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
add a comment |
How to get back from tabbar controller depends on how you got to it in the first plase.
If you pushed it into navigation stack, you need to call popViewController(animated:)
. This is clearly not your case.
You could've presented it modally. Then you need to dismiss(animated:, completion:)
.
If you set the tabbar controller as the window's root, then you need to reset the root with your HomeViewController
. E.g.
UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
How to get back from tabbar controller depends on how you got to it in the first plase.
If you pushed it into navigation stack, you need to call popViewController(animated:)
. This is clearly not your case.
You could've presented it modally. Then you need to dismiss(animated:, completion:)
.
If you set the tabbar controller as the window's root, then you need to reset the root with your HomeViewController
. E.g.
UIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
answered Nov 22 '18 at 7:15
EvgeniyEvgeniy
475413
475413
add a comment |
add a comment |
You should custom a UITabBarViewController
When you want go to TabBarVC from Home, you push a navigation has root is a TabBarViewController.
At TabBarViewController, if you want to back to Home, call popToViewController method of nagicationVC.
Ex:
class HomeVC: UIViewController {
@IBAction func goToTabBarVC(_ sender: Any) {
let tabBar = TabBarVC()
let navigation = UINavigationController(rootViewController: tabBar)
navigationController?.pushViewController(navigation, animated: true)
}
}
class TabBarVC: UITabBarController {
@IBAction func backToHome(_ sender: Any) {
navigationController?.popViewController(animated: true)
}
}
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
add a comment |
You should custom a UITabBarViewController
When you want go to TabBarVC from Home, you push a navigation has root is a TabBarViewController.
At TabBarViewController, if you want to back to Home, call popToViewController method of nagicationVC.
Ex:
class HomeVC: UIViewController {
@IBAction func goToTabBarVC(_ sender: Any) {
let tabBar = TabBarVC()
let navigation = UINavigationController(rootViewController: tabBar)
navigationController?.pushViewController(navigation, animated: true)
}
}
class TabBarVC: UITabBarController {
@IBAction func backToHome(_ sender: Any) {
navigationController?.popViewController(animated: true)
}
}
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
add a comment |
You should custom a UITabBarViewController
When you want go to TabBarVC from Home, you push a navigation has root is a TabBarViewController.
At TabBarViewController, if you want to back to Home, call popToViewController method of nagicationVC.
Ex:
class HomeVC: UIViewController {
@IBAction func goToTabBarVC(_ sender: Any) {
let tabBar = TabBarVC()
let navigation = UINavigationController(rootViewController: tabBar)
navigationController?.pushViewController(navigation, animated: true)
}
}
class TabBarVC: UITabBarController {
@IBAction func backToHome(_ sender: Any) {
navigationController?.popViewController(animated: true)
}
}
You should custom a UITabBarViewController
When you want go to TabBarVC from Home, you push a navigation has root is a TabBarViewController.
At TabBarViewController, if you want to back to Home, call popToViewController method of nagicationVC.
Ex:
class HomeVC: UIViewController {
@IBAction func goToTabBarVC(_ sender: Any) {
let tabBar = TabBarVC()
let navigation = UINavigationController(rootViewController: tabBar)
navigationController?.pushViewController(navigation, animated: true)
}
}
class TabBarVC: UITabBarController {
@IBAction func backToHome(_ sender: Any) {
navigationController?.popViewController(animated: true)
}
}
answered Nov 22 '18 at 7:19
Leo LELeo LE
215
215
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
add a comment |
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
– MeMouli
Nov 22 '18 at 7:46
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
I only given a idea, it not enough code to compile success. You must add some code, ex HomeViewController is child of a UINavigationController.
– Leo LE
Nov 23 '18 at 6:41
add a comment |
In the app delegate file put following code in applicationDidFinishLaunching method.
let st = UIStoryboard(name: "Main", bundle: nil)
let homeVC = [st initializeViewControllerWithIdentifier:"HomeVC"]
let navigation = UINavigationController(rootViewController: homeVC)
self.window??.rootViewController = navigation
or
You can directly embed the Navigation controller to the home view controller from storyboard.
Thanks
add a comment |
In the app delegate file put following code in applicationDidFinishLaunching method.
let st = UIStoryboard(name: "Main", bundle: nil)
let homeVC = [st initializeViewControllerWithIdentifier:"HomeVC"]
let navigation = UINavigationController(rootViewController: homeVC)
self.window??.rootViewController = navigation
or
You can directly embed the Navigation controller to the home view controller from storyboard.
Thanks
add a comment |
In the app delegate file put following code in applicationDidFinishLaunching method.
let st = UIStoryboard(name: "Main", bundle: nil)
let homeVC = [st initializeViewControllerWithIdentifier:"HomeVC"]
let navigation = UINavigationController(rootViewController: homeVC)
self.window??.rootViewController = navigation
or
You can directly embed the Navigation controller to the home view controller from storyboard.
Thanks
In the app delegate file put following code in applicationDidFinishLaunching method.
let st = UIStoryboard(name: "Main", bundle: nil)
let homeVC = [st initializeViewControllerWithIdentifier:"HomeVC"]
let navigation = UINavigationController(rootViewController: homeVC)
self.window??.rootViewController = navigation
or
You can directly embed the Navigation controller to the home view controller from storyboard.
Thanks
edited Nov 22 '18 at 8:02
John Kennedy
2,61321026
2,61321026
answered Nov 22 '18 at 7:33
hpphpp
584212
584212
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53425391%2fhow-to-get-back-from-tabbar-view-controller%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you show how you are adding
tabBarController
fromHomeViewController
? Most probably you can doUIApplication.shared.delegate?.window??.rootViewController = HomeViewController()
– Kamran
Nov 22 '18 at 6:58
I am using button for navigation from HomeViewController to Tabbar ViewController @Kamran
– MeMouli
Nov 22 '18 at 7:02
1
How are you moving from HomeViewController to Tab Controller? Are you using navigation controller to push your Tabbar ViewController?
– Natarajan
Nov 22 '18 at 7:08
Have you initialize your HomeViewController with NavigationController?
– hpp
Nov 22 '18 at 7:29
yes i initialize HomeViewController with NavigationController
– MeMouli
Nov 22 '18 at 9:46