I two bar button items and one search bar in a navigation bar added them programmatically
but when i tried to localize this view just from changing the app language it works perfect but it's changing the position of the bar button item (slide menu button) from left to right and i don't want this to be happened and it make the bar button of the men in a side and the view of the menu in another side like this image below:
and this when tapping the menu button to show it it's showing the menu in another place :
so i just want to stop flipping the bar button items when trying to switch between two different languages and i tried to change the semantic of the navigation controller from story board and programmatically and nothing happened and by the way bar button item has no semantic to control by it self and thanks in advance hope you can help me
Use rightAnchor instead of trailingAnchor constraint
For menu you have to set
SideMenuManager.default.leftMenuNavigationController
SideMenuManager.default.rightMenuNavigationController
then choose which one will open depend on your language.
like this
if MOLHLanguage.currentAppleLanguage() == "en"{
let menu = SideMenuManager.default.leftMenuNavigationController!
present(menu, animated: true, completion: nil)
}else {
let menu = SideMenuManager.default.rightMenuNavigationController!
present(menu, animated: true, completion: nil)
}
Related
I use PTCardTabBarController like custom tab bar. I want to hide tab bar in my ViewController. I trying to use in storyboard Hide Bottom Bar on Push or in code: self.tabBarController?.tabBar.isHidden = true. But it not helped me.
When I stat to use PTCardTabBar I have next scheme in storyboard:
TabBarController (with class PTCardTabBarController and module PTCardTabBar) -> NavigationBarController -> ViewController.
Next I launch my app and I see under my PTCardTabBar system iOS tab bar. I use in storyboard Hide Bottom Bar on Push but it is hide only system tab bar and not PTCardTabBar. How to fix it and hide both tab bars?
Taking a quick look at that PTCardTabBar library...
What you see on-screen is not a UITabBar ... it is a UIView. So, any normal actions on a standard Tab Bar Controller's TabBar will not be related.
To hide it, you need to edit PTCardTabBarController.swift and make its customTabBar available to your code:
// make this "open"
open lazy var customTabBar: PTCardTabBar = {
return PTCardTabBar()
}()
Then, when you want to hide the tab bar (for example, in viewDidLoad() in your view controller:
if let ptcTBC = tabBarController as? PTCardTabBarController {
ptcTBC.customTabBar.isHidden = true
}
You'll also (obviously) need to set .isHidden back to false to show it again.
Probably, though, you want to do more than just have it showing or hidden... in which case you could further modify PTCardTabBarController.swift to add a function to animate it into or out-of view (for example).
I'm using MvxTabBarViewController that is attributed with:
[MvxFromStoryboard("Main")]
[MvxRootPresentation(WrapInNavigationController = true)]
It does not present "More" button when I have more than five tabs added to the controller. Instead only the first four are shown.
The tabs are MvxViewControllers that are attributed with:
[MvxFromStoryboard("Main")]
[MvxTabPresentation(WrapInNavigationController = false, TabIconName = "icon", TabName = "Tab 1")]
They are presented from ViewWillAppear(bool animated) method using NavigationService.Navigate(TabOneViewModel)
I tried setting WrapInNavigationController to false, but still no luck.
Any help would be appreciated.
When using a Storyboard, in order to add a TabBarController to your application you need to drag and drop a UITabBarViewController instead of a plain UIViewController. Otherwise some properties are not correctly derived (like the TabBar in this case - please see my screenshot).
Just make sure you delete the automatically created TabBar items!
I have built a simple tab bar with 3 tabs.
I want to run a UI test to make sure that if the user clicks a tab bar item, the correct view controller shows. How would I go about doing that? Below is the code I would start with, just don't know how to write my assertion.
func testTabBarMyProfileButton() {
let tabBarsQuery = XCUIApplication().tabBars
tabBarsQuery.buttons["My Profile"].tap()
}
func testTabBarGraphsButton() {
let tabBarsQuery = XCUIApplication().tabBars
tabBarsQuery.buttons["Graphs"].tap()
}
func testTabBarAboutButton() {
let tabBarsQuery = XCUIApplication().tabBars
tabBarsQuery.buttons["About"].tap()
}
You can access the tabbar button by its position:
app.tabBars.buttons.element(boundBy: 2).tap()
If you have different controls in each view controller shown on each tab bar, you can make assertions if they exist or not (what is expected).
For example if the first tab bar has UILabel named "First name" you can assert if it exists by writing
Let theLabel = app.staticTexts["myValue"]
XCTAssert(theLabel.exists).to(beTrue)
And on the other screens do the same thing for the different controls.
If anyone finds this looking to UI test the contents of another app, I just found a solution..
The tab bar item is a lazy variable and needs to be touched before you can reference a tab bar button by value. Add this line:
tabBarItem.accessibilityIdentifier = "my-snazzy-identifier"
to the viewDidLoad method and you should be able to do this in your UI tests:
app.tabBars.buttons["Button Title"].tap()
You can test the title of the navigation bar.
XCTAssert(app.navigationBars["Graphs"].exists)
See my GitHub repo for a more detailed UI Testing example.
I am working on a project which contain a tab bar. The tab bar contain 2 items named leave and Od. Both are normal viewcontroller class. They have a table view inside it(I dont mean table view controller). While clicking on a item in a table view a pop Up screen appears which have a viewcontroller swift file named as popUpviewController. This show details of item selected in table view. The problem is when i dismiss the popUpdialog i always get the selected tabBar item as the default one.Here its leave authorise.
what I did is i gave an Storyboard Id to tab Bar controller and called it from the popUp when its dismissed, like this.
let viewController:UIViewController = UIStoryboard(name:self.whichSB!, bundle: nil).instantiateViewControllerWithIdentifier("AuthoriseTabBar?") as UIViewController
self.tabBarController?.selectedIndex=2 /* DOESN'T WORK OBVIOUSLY*/
self.presentViewController(viewController, animated: false, completion: nil)
** The tab bar controller doesn't have any associated class with it.I would like to show item 1 when item1 popUp is dismissed(This works as its now the default item shown in tab bar), and item 2 when item 2 popUp is dismissed.**
Can anyone suggest a away of doing the above . and I havent used any navigation controller here, is it necessory to get tabbar.selectedindex of tab bar
You can access the tab bar, from the popup VC, like this. Just run this with the normal dismiss line as shown.
if let presentingVC = self.presentingViewController {
if let tabController = presentingVC.tabBarController {
tabController.selectedIndex = 0 // Whatever index you want to select.
}
}
self.dismiss(animated: true, completion: nil)
I am using tab bar controller as main and following way-
UITabbarController -> UINavigationController -> UITableViewController (with 5 tab bar & uncheck show navigation bar & made UIView with mail box image as button then click ) -> ViewController (with 5 tab bar & without back button )
I want to get back button as first tab bar title name like < Home
Please let me know the programmatic or structure way.
Thanks
Try to hide titleView label
self.navigationItem.titleView = UIView()
You need to remove the text from the back button. The simplest way is to set it as empty string, like this
self.navigationController?.navigationBar.backItem?.title = ""
You are looking for this
self.navigationController?.navigationBar.backItem?.title = "TEXT"