I'd like to create pager tab like InstagramExample of XLPagerTabStrip and I follow all layout and coding to get the same. After adding everything I cannot see the title label on pager tab but I can swipe views as much as I add in array. Could anyone help me with this issue, please? I use the latest version of XLPagerTabStrip (v7.0.0).
The pager tab is covered by NavigationBar.
so ,you can
1: to hide NavigationBar
self.navigationController?.isNavigationBarHidden = true
2: to move tab
//get rod of containerView offset
edgesForExtendedLayout = []
//move tab
buttonBarView.frame.origin.y = buttonBarView.frame.origin.y + 30
Related
In the image shared, the orange section is the bar section , which is having unnecessary height, I am not able to resolve this issue by myself.
the views are like this
Parent Controller = View Controller
Child views = green view, black tableview
Please help to correct the height of the orange bar.
Seems like you have enabled prefersLargeTitles.
Make it false in your viewWillAppear()
self.navigationController?.navigationBar.prefersLargeTitles = false
You can also disable it from the storyboard.
Select your Navigation Controller -> Navigation Bar -> Uncheck prefers large titles
it seems like you're using the largeTitles on the navigationBar,
var prefersLargeTitles: Bool { get set }
When this property is set to true, the navigation bar allows the
title to be displayed out-of-line and using a larger font. The
navigation item used to build the bar must specify whether it wants
its title displayed in the large or small format. Use the
largeTitleDisplayMode property to configure the title's appearance.
When the property is set to false, the navigation bar displays the
title inline with the other bar button items.
try to disable it by:
navigationController?.navigationBar.prefersLargeTitles = false
or you can do this as well:
navigationItem.largeTitleDisplayMode = .never
hope this helps:)
https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitles
I have a Tab Bar with some view controllers, and one of the controller contains a TableView. My problem is that it appears in black 90% of the time.
May be it is linked I think to the constraint, the size, because if I touch the constraint, the size, the frame origin, some times it is not black.
Impossible to avoid the blackscreen, and a tableview well displayed with the good size, at the good position. It is very frustrating because all is working on the other 4 viewcontrollers except that view that contains the tableview.
Storyboard viewcontroller:
viewController on simulator with no constraints:
viewControlelr on simulator with constraints (whatever the change I do, it doesn't display correctly. The buttons disappear, the label too).
I tried the solutions in this tickets with no success:
self.definesPresentationContext = true
Link 1
Link 2
Link 3
(I precise that I am trying to find a solution to this, not adding lots of navigationcontrollers after the tabBar or changing the tab bar method itself)
Any suggestions?
EDIT: Here is all the constraints:
You should use the navigationController for each view controller of your tab bar because it is a bug in the storyboard that haven't been resolved until today
1/ Put the line self.definesPresentationContext = true in each view of the tabbarviewcontroller
2 / Editor/Embed/NavigationController for each view of the tabBarViewController
3 / Remove "Show Navigation Bar " for each Navigation Controller of all the viewControllers of the TabBarViewController
4 / Instead of
let vc = self.tabBarController!.viewControllers![1] as! YourViewController
Put this line :
let nc = self.tabBarController!.viewControllers![1] as! UINavigationController
let vc: YourViewController = nc.viewControllers[0] as! YourViewController
5 / resolve all the constaints issues (in red, and in yellow in the storyboard)
6 / Remove the app before compilation on simulator or device
7 / Before the compilation, do a hard clean (Cmd + option + Shift + k)
8 / optional : in some case, close XCode, and relaunch it
I have a UINavigationController embedded inside a UITabBarController.
The problem is that my content always appears underneath the bars. I have a collection view with x & y set to 0 which appears fine. The green view however is just a simple UIView with the same x & y positions.
My question is, how can I make the content properly show at the expected y coordinate of 0?
Set the isTranslucent property to false on both the navigation bar and the tab bar.
For the nav bar:
navigationController.navigationBar.isTranslucent = false
For the tab bar:
tabBarController.tabBar.isTranslucent = false
Where you do this will depend on how your code is structured, but the easiest spot for each will likely be right after you initialize the tab bar controller and the navigation controller.
I'm trying to implement the swipe to view functionality just like Twitter's Moments:
If you take a look at the top you'll see a horizontal slider with the views. My requirement is tad bit different... On top of that horizontal slider I need my regular navigation bar with each page's custom items.
The swipe to view I implemented with some minor errors. Please take a look at this video (this is what I've done so far):
http://sendvid.com/5j50p73z
As you can see the swipe views functionality is working but I'm still missing some important things, namely:
When swiping to the next view it is scrolling up (seen on video)
My views are all contained in navigation controllers with their respective navbar items. The way I see it I'd need something like PushViewController without the back button but that would work both directions... I'm kinda lost here If I add the navigation controller instead of the view it shows the bar, but below the current existing one, not substituting it.
Any ideas on how to solve these?
I'm developing using Xamarin.iOS, but if you can provide an example using swift I guess I could try to translate that :)
This is what I have so far:
var viewController = Storyboard.InstantiateViewController("detailClaimViewController") as DetailClaimViewController;
viewController.ClaimId = ClaimId;
AddChildViewController(viewController);
ScrollView.AddSubview(viewController.View);
viewController.DidMoveToParentViewController(this);
var sumsInsController = Storyboard.InstantiateViewController("sumsInsuredListViewController")
as SumsInsuredListViewController;
var sumsInsuredFrame = sumsInsController.View.Frame;
sumsInsuredFrame.X = View.Frame.Size.Width;
sumsInsController.View.Frame = sumsInsuredFrame;
sumsInsController.ClaimId = ClaimId;
sumsInsController.Title = $"Sums insured for {Title}";
AddChildViewController(sumsInsController);
ScrollView.AddSubview(sumsInsController.View);
sumsInsController.DidMoveToParentViewController(this);
ScrollView.ContentSize = new CGSize(View.Frame.Size.Width * 2, View.Frame.Size.Height - 49);
This is the code I "need" to work, because it loads the navigation bar and that ViewController's custom navbar items (as I said this one "works" but it shows the correct navigation bar below the standard one, it doesn't substitute it):
var viewController = Storyboard.InstantiateViewController("detailClaimViewController") as DetailClaimViewController;
viewController.ClaimId = ClaimId;
AddChildViewController(viewController);
ScrollView.AddSubview(viewController.View);
viewController.DidMoveToParentViewController(this);
var navController = new UINavigationController();
var sumsInsController = Storyboard.InstantiateViewController("sumsInsuredListViewController")
as SumsInsuredListViewController;
var sumsInsuredFrame = sumsInsController.View.Frame;
sumsInsuredFrame.X = View.Frame.Size.Width;
sumsInsController.View.Frame = sumsInsuredFrame;
sumsInsController.ClaimId = ClaimId;
sumsInsController.Title = $"Sums insured for {Title}";
navController.AddChildViewController(sumsInsController);
AddChildViewController(navController);
ScrollView.AddSubview(navController.View);
navController.DidMoveToParentViewController(this);
ScrollView.ContentSize = new CGSize(View.Frame.Size.Width * 2, View.Frame.Size.Height - 49);
Thank you!
Navigation items are defined per contained view controller within a UINavigationController. You can work around that in different ways, but my recommendation would be to use a custom UIViewController that acts as the container for the other UIViewControllers you want to present.
For example, you could build a custom UIViewController that contains your custom navigation bar and a view for the content itself, to act as a custom UINavigationController. With custom transitions, you can mimic the behaviour of the original class.
Please refer to this document for a better explanation on container view controllers.
I'm took the Tabbar viewcontroller in this ,I added the 5 item and .I given the image insects is (24,0,0,6).
All button images are added in xib [under the Bar item -->image]Please help.
Thanks.
Adding to a similar answer here:
iOS Tab Bar icons keep getting larger
Not sure if this is an iOS7 bug but I've noticed that image insets need to be balanced.
You have specified insets for top and right but:
if you set a top inset, in order to balance it, you need to set the negative of it to the bottom inset
if you set a right inset, in order to balance it, you need to set the negative of it to the left inset
So, instead of having image insets like (24,0,0,6), use balanced image insets such as UIEdgeInsetsMake(24,-6,-24,6)
Doing so should protect your tabBarItem image from getting whacked on every tap.
If this doesn't suit your requirements, then redesign your tabBarItem image so you can have balance insets or... no insets at all.
Here's the workaround for a bug I've encountered with UITabBarController's UITabBar. If I tap a UITabBarItem once after it's selected, the icon shrinks. What I'd like to do is disable touches. UITabBarItem only has a setting for isEnabled, which grays it out if I set it to false...not what I was looking for.
I used a derivative of this answer to figure it out. With a UITabBarController with 3 tabs, printing tabBarController.subviews, I saw 3 UITabBarButtons and a UIBarBackground. The origin of UIBarBackground's frame was always (0, 0), putting it at the front of the sorted array, so I really don't need to know what the subview is, just "where it is" and whether it will always be there. The UIBarBackground is always going to be at the front of an array of tabBarController.subviews sorted by frame.minX, so I just need to remove it from the front.
Solution
Here's what the extension looks like:
extension UITabBarController {
var buttonViews: [UIView] {
var tabBarButtons = tabBar.subviews.sorted(by: {$0.frame.minX < $1.frame.minX})
tabBarButtons.removeFirst()
return tabBarButtons
}
}
I also created a struct in my Constants file, so I don't have to remember tab names:
struct TabBarItem {
static let firstTab = 0
static let secondTab = 1
static let thirdTab = 2
}
...and finally, where to use it:
In viewDidAppear (NOT viewDidLoad), add the following line to disable the UITabBarItem that you don't want to disable, but not gray out:
tabBarController?.buttonViews[TabBarItem.firstTab].isUserInteractionEnabled = false
In viewWillDisappear, re-enable the tab, as follows:
tabBarController?.buttonViews[TabBarItem.firstTab].isUserInteractionEnabled = true