New to swift 4 programming need help in UIButton.
There are two buttons for appointments, one on tabbar and other is UIButton.
How can i program that UIButton to navigate to “Appointments UIView on UITabbar” without disappearing the tabbar when navigating?
I don't know if I understand you well, but if I'm right you want to access a specific tab by touching a UIButton, not the UITabBarController.
Solution for this is adding an action to your button like below:
#IBAction func goToAppointments(sender: AnyObject) {
tabBarController?.selectedIndex = x
}
Where x is an integer with the position of "Appointments Tab" in tab bar.
Related
I have 4 main ViewControllers that are connected to a UITabBarController. These are the 4 main screens of my application. Each of these 4 screens has an icon on the TabBar.
Now, from within one of these main screens, I want to be able to click a button to show a new "child" view controller. When I segue from the MainVC to the ChildVC, the UITabBar does not show on the ChildVC. How can I get the UITabBar to remain shown? I do not want to add the ChildVC to the UITabBar, as it should not have an icon on the bar.
I am open to using any type of segue or combination of views.
Within MainVC, I want to click a button to show ChildVC WITHOUT losing the UITTabBar from the MainVC (and without adding ChildVC as an icon to UITabBar).
If I understood your question's hypothesis correctly, you should stack all 4 “main screens” into separate navigation stacks (UINavigationController).
So the outcome would be:
UITabBarController -> UINavigationController -> UIViewController (1 of those main screens) click button -> Desired UIViewController
Have a look at this: https://stackoverflow.com/a/27425271/8290785
I have a bit of complex issue with a UITabBarItem it's UIViewController. Basically I have a series of UIButtons which is a layer on top of UITabBar, if the a UIButton is selected the right UITabBarItem is selected.
The complex issue starts when I have a UIViewController that is displayed when one of the UITabBarItem is pressed this takes the whole screen and displays a series of UIButtons. Once you press a button it returns back to the UITabBarItem selected but what I want in the UIViewcontroller is to have a dynamic UIView. I can get everything else working except that because the viewDidLoad is pre-loaded within that view.
Any suggestions. Sorry if that was a mouthful!
Now that I understand what you are asking, it seems that you need the view within the fifth tab to change based on what button is pressed - you can achieve this by making a bunch of graphic buttons to fill the view, then to have the fullscreen overlay you need to have your view present the new view as a modal view controller.
[self presentModalViewController:controllerForButton1 animated:NO]
This actually doesn't have much to with tab bars, this just happens to be within a tab bar controller, and they used the fifth view to hold a big menu, because there weren't enough tabs to suit their need.
Basically what I have is View with a series of UIButtons and depending on what button is pressed a View with UITabBar is displayed with a certain UITabBarItem selected. This works out fine, however what I want to do is to change the UIView within the UITabBarItem.
So for example: I have 8 buttons on the my first view. I press button 1 and UITabBarItem 2 is selected and View A is displayed, however if I press button 2 UITabBarItem 2 is selected but instead of View A it displays View B.
What exactly is happening is, if I have viewDidLoad method the code within is preloaded before I can change it dynamically. So I tried using viewWillAppear but nothing seems to happen.
Any help will be appreciated. I hope I have made my question clear enough for everyone.
try to implement the uitabbarcontroller protocol and overwrite
these methods:
– tabBarController:shouldSelectViewController:
– tabBarController:didSelectViewController:
i am new to iphone dev, i want to add a button (sign out) which remains fixed on the navigation bar's right side for every view.i.e. even when tabs of TabBar are tapped, the Sign Out button should remain fixed.
Any help/suggestions would be appreciated.
Thanks
Since each UIViewController has its own navigation item (a set of views in the navigation bar), you have to add the same button in each view controller's -viewDidLoad method. If the same button is used everywhere in your app, it makes sense to create a subclass of UIViewController which does just that and reuse this subclass throughout your app.
I have added a custom button (subclass UIButton) to my navigation bar but the button does not change states when clicked.
The button is configured correctly as it does work in, for example, a table view.
All advice is welcome.
Have you tried subclassing UIBarButton instead of UIButton?
I got it working. What I forgot to implement was the method to change the button selection states.