Swift: Pop from one tab to another tab - swift

Have a tabBar Application in which there are five tabs and in one tab have added back button and i want to pop back using back button. how can it be done? have tried below code and it doesn't work
self.navigationController?.popToRootViewControllerAnimated(true)

Related

Swift 4: Click button to next View Controller but the new page's animation is "cover vertically" instead of "shifting" to next page

I am newbie of Swift 4 and I am trying to simply click a button and go to next page.
So I add a button in the first page and another view controller. Then I drag the button to the next page to create the "transaction". However, the animation of the transaction to pop up the next page from bottom, as shown in the image below. What I expect is to shift horizontally from current page to next page. Where did I do wrong? How can I achieve this?
Select the first view controller and choose Editor > Embed In > Navigation Controller. Make sure your segue is Show (Push).

Need an ideal way to handle tab bar in app

I want to create an app where there is a login screen, and when user logs in open up home page with tab bar controller.
I have created a single view application and have created login screen, home screen and a tab bar on it.
In tab bar delegate, I am adding screens to tab bar by [self.view addSubView firstView.view]
My problem is if I open up 4th tab, and switch to 2nd tab and I have to go back to home screen, so I press home btw on nav bar, it shows view 4 which is already on stack of uiviews.
How do I switch between all tab bar views and add navigation to them ? Which ideal method is to be used?
I've created app that is doing what you need (I guess). You can find it in app store for iphone using name Torchoo. It is free and there is test account so you can see how it works and if its really what you need. If yes, ping me here I will show you the sources and how I did it.
In couple of words, you need normal tabbar controller that has number of navigation controllers and each of them has number of view controllers. And login screen is just a modal view that shows/hides when you need it. Most of things may be done in storyboard.
I don't get it actually but i think you want to attach all the view by navigation controller.
But it's useless. if you want to use navigation bar then it ll navigate in another view but tabbar will give you different views on every tab.
so, first see the use of both of them then ask....

Navigation title / item disappears on switching tab bar item in action sheet clickedButtonAtIndex?

I'm really pulling my hair out over this one.
I'm showing an action sheet on the first view controller within my first tab bar item, when I tap OK, I'm switching to another view within another tab bar item, using the following code.
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
self.tabBarController.selectedIndex = 1;
}
(I assign view controllers to a navigation controller, then to a tab within my app delegate, repeating the process for each tab).
On return from second tab, when I tap tab item one the title and info button has gone.
If I go to next view in the navigation stack within the first tab and back, the title returns.
Here's my first view, I'm about to tap the info buttons.
This shows an action sheet
Yes I do need all though buttons, tap on the second one
OK, it switched me to the second tab.
Now I tap tab one.
All my navigation items are gone!!!
I've also tried adding a label as a title using...
self.navigationItem.titleView
However this is lost too.
My theory here is that in my action sheet clickedButtonAtIndex event (where I've running selectedIndex), the event isn't finishing correctly before it switches to the next tab.
Here's the scenario
Any suggestions ?
Since this is such a complex problem I have created a
sample project.
Take this sample code... and then run. I don't have such problem

Is is possible to add a 5th tab bar button instead of "More" Button?

I'm working on an iphone application that has exactly 5 tab bar buttons.
I've created a custom tab bar and added 5 buttons to it, each with a separate view controller.
The buttons are showing fine, but the 5th view controller is not loading on 5th tab bar button press. This might be because the 5th button is supposed to be the "More" button. Is their some way to override it?
No the more button wil only show if you have more then 5 viewcontroller in the tabbarcontroller.
You can customize your tab bar to do so.
There're some exist ones, like the one below:
https://github.com/boctor/idev-recipes/tree/master/CustomTabBar
It works Excelent! And you'll see the screenshot that it use five tabs. :)
AS per apple human interface guidelines if you have more than 4 tabs last tab is displayed as more tab and you can not alter it

NavigationBar Right Button Problem

I have a navigation bar in my app. The below pictures are in the order of navigation.
Problem I have is, on clicking the "Main" button , I am able to perform the action and goto the required screen , but the navigation bar does not look like the first on (with Menu as left button). Instead it look like 4th image. How to make it look like first image so that I can make the user to navigate to "Menu" screen by clicking menu button ?. Thanks for the help …!!!
If I'm understanding this correctly, you may have pushed the first view controller (The one from screenshot 1) when clicking on main which is why you see "lens" in the back button. That back button takes the title of the previous view controller in the stack. What you want to do is pop to the first view controller when they click on Main using either popToRootViewController or popToViewController:animated