Tabbar controller issue
I am using tab bar controller using xib but when I include one vc there is space remaining in that vc at the end. Here is video of my problem
Here is my viewcontroller xib and code
Please help me with it
here is my tabbar controller code
import UIKit
class TabbarControllerVC: UITabBarController, UITabBarControllerDelegate{
let homeVC = HomeVC(nibName: "HomeVC", bundle: nil)
let listVC = HomeVC(nibName: "HomeVC", bundle: nil)
let notificationVC = HomeVC(nibName: "HomeVC", bundle: nil)
let settingVC = MyProfileVC(nibName: "MyProfileVC", bundle: nil)
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
tabBar.tintColor = ColorConstants.ThemeColor
var tabbarControllers = [UIViewController]()
tabbarControllers.append(homeVC)
tabbarControllers.append(listVC)
tabbarControllers.append(notificationVC)
tabbarControllers.append(settingVC)
self.setViewControllers(tabbarControllers, animated: true)
homeVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Home"), selectedImage: UIImage(named : "Home"))
listVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "List"), selectedImage: UIImage(named : "List"))
notificationVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Notification"), selectedImage: UIImage(named : "Notification"))
settingVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Setting"), selectedImage: UIImage(named : "Setting"))
UITabBar.appearance().tintColor = ColorConstants.ThemeColor
homeVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
listVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
notificationVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
settingVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
if #available(iOS 10.0, *) {
UITabBar.appearance().unselectedItemTintColor = ColorConstants.BlackColor
} else {
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: ColorConstants.BlackColor], for: .normal)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setupTabBarSeparators() {
let itemWidth = floor(self.tabBar.frame.size.width / CGFloat(self.tabBar.items!.count))
// this is the separator width. 0.5px matches the line at the top of the tab bar
let separatorWidth: CGFloat = 0.5
// iterate through the items in the Tab Bar, except the last one
for i in 0...(self.tabBar.items!.count - 1) {
// make a new separator at the end of each tab bar item
let separator = UIView(frame: CGRect(x: itemWidth * CGFloat(i + 1) - CGFloat(separatorWidth / 2) , y: 15, width: CGFloat(separatorWidth), height: self.tabBar.frame.size.height - 30))
// set the color to light gray (default line color for tab bar)
separator.backgroundColor = UIColor.lightGray
self.tabBar.addSubview(separator)
}
}
override func viewWillAppear(_ animated : Bool){
super.viewWillAppear(true)
setupTabBarSeparators()
}
}
ios swift uiviewcontroller uitabbarcontroller tabbar
add a comment |
I am using tab bar controller using xib but when I include one vc there is space remaining in that vc at the end. Here is video of my problem
Here is my viewcontroller xib and code
Please help me with it
here is my tabbar controller code
import UIKit
class TabbarControllerVC: UITabBarController, UITabBarControllerDelegate{
let homeVC = HomeVC(nibName: "HomeVC", bundle: nil)
let listVC = HomeVC(nibName: "HomeVC", bundle: nil)
let notificationVC = HomeVC(nibName: "HomeVC", bundle: nil)
let settingVC = MyProfileVC(nibName: "MyProfileVC", bundle: nil)
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
tabBar.tintColor = ColorConstants.ThemeColor
var tabbarControllers = [UIViewController]()
tabbarControllers.append(homeVC)
tabbarControllers.append(listVC)
tabbarControllers.append(notificationVC)
tabbarControllers.append(settingVC)
self.setViewControllers(tabbarControllers, animated: true)
homeVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Home"), selectedImage: UIImage(named : "Home"))
listVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "List"), selectedImage: UIImage(named : "List"))
notificationVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Notification"), selectedImage: UIImage(named : "Notification"))
settingVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Setting"), selectedImage: UIImage(named : "Setting"))
UITabBar.appearance().tintColor = ColorConstants.ThemeColor
homeVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
listVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
notificationVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
settingVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
if #available(iOS 10.0, *) {
UITabBar.appearance().unselectedItemTintColor = ColorConstants.BlackColor
} else {
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: ColorConstants.BlackColor], for: .normal)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setupTabBarSeparators() {
let itemWidth = floor(self.tabBar.frame.size.width / CGFloat(self.tabBar.items!.count))
// this is the separator width. 0.5px matches the line at the top of the tab bar
let separatorWidth: CGFloat = 0.5
// iterate through the items in the Tab Bar, except the last one
for i in 0...(self.tabBar.items!.count - 1) {
// make a new separator at the end of each tab bar item
let separator = UIView(frame: CGRect(x: itemWidth * CGFloat(i + 1) - CGFloat(separatorWidth / 2) , y: 15, width: CGFloat(separatorWidth), height: self.tabBar.frame.size.height - 30))
// set the color to light gray (default line color for tab bar)
separator.backgroundColor = UIColor.lightGray
self.tabBar.addSubview(separator)
}
}
override func viewWillAppear(_ animated : Bool){
super.viewWillAppear(true)
setupTabBarSeparators()
}
}
ios swift uiviewcontroller uitabbarcontroller tabbar
I think your problem is in the view controllers. share the HomeVC code.
– Tal Cohen
Nov 25 '18 at 8:33
It's much code to look at :) Try to use View Hierarchy Debugger to debug your view and understand which one is causing the problem. or try to isolate the problem in some other way and ask a more specific question.
– Tal Cohen
Nov 25 '18 at 8:45
Did you tryextendedLayoutIncludesOpaqueBars
andautomaticallyAdjustsScrollViewInsets
?
– Geru
Nov 25 '18 at 9:06
No, Please tell me more about it
– Jitendra Modi
Nov 26 '18 at 7:39
add a comment |
I am using tab bar controller using xib but when I include one vc there is space remaining in that vc at the end. Here is video of my problem
Here is my viewcontroller xib and code
Please help me with it
here is my tabbar controller code
import UIKit
class TabbarControllerVC: UITabBarController, UITabBarControllerDelegate{
let homeVC = HomeVC(nibName: "HomeVC", bundle: nil)
let listVC = HomeVC(nibName: "HomeVC", bundle: nil)
let notificationVC = HomeVC(nibName: "HomeVC", bundle: nil)
let settingVC = MyProfileVC(nibName: "MyProfileVC", bundle: nil)
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
tabBar.tintColor = ColorConstants.ThemeColor
var tabbarControllers = [UIViewController]()
tabbarControllers.append(homeVC)
tabbarControllers.append(listVC)
tabbarControllers.append(notificationVC)
tabbarControllers.append(settingVC)
self.setViewControllers(tabbarControllers, animated: true)
homeVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Home"), selectedImage: UIImage(named : "Home"))
listVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "List"), selectedImage: UIImage(named : "List"))
notificationVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Notification"), selectedImage: UIImage(named : "Notification"))
settingVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Setting"), selectedImage: UIImage(named : "Setting"))
UITabBar.appearance().tintColor = ColorConstants.ThemeColor
homeVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
listVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
notificationVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
settingVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
if #available(iOS 10.0, *) {
UITabBar.appearance().unselectedItemTintColor = ColorConstants.BlackColor
} else {
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: ColorConstants.BlackColor], for: .normal)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setupTabBarSeparators() {
let itemWidth = floor(self.tabBar.frame.size.width / CGFloat(self.tabBar.items!.count))
// this is the separator width. 0.5px matches the line at the top of the tab bar
let separatorWidth: CGFloat = 0.5
// iterate through the items in the Tab Bar, except the last one
for i in 0...(self.tabBar.items!.count - 1) {
// make a new separator at the end of each tab bar item
let separator = UIView(frame: CGRect(x: itemWidth * CGFloat(i + 1) - CGFloat(separatorWidth / 2) , y: 15, width: CGFloat(separatorWidth), height: self.tabBar.frame.size.height - 30))
// set the color to light gray (default line color for tab bar)
separator.backgroundColor = UIColor.lightGray
self.tabBar.addSubview(separator)
}
}
override func viewWillAppear(_ animated : Bool){
super.viewWillAppear(true)
setupTabBarSeparators()
}
}
ios swift uiviewcontroller uitabbarcontroller tabbar
I am using tab bar controller using xib but when I include one vc there is space remaining in that vc at the end. Here is video of my problem
Here is my viewcontroller xib and code
Please help me with it
here is my tabbar controller code
import UIKit
class TabbarControllerVC: UITabBarController, UITabBarControllerDelegate{
let homeVC = HomeVC(nibName: "HomeVC", bundle: nil)
let listVC = HomeVC(nibName: "HomeVC", bundle: nil)
let notificationVC = HomeVC(nibName: "HomeVC", bundle: nil)
let settingVC = MyProfileVC(nibName: "MyProfileVC", bundle: nil)
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
tabBar.tintColor = ColorConstants.ThemeColor
var tabbarControllers = [UIViewController]()
tabbarControllers.append(homeVC)
tabbarControllers.append(listVC)
tabbarControllers.append(notificationVC)
tabbarControllers.append(settingVC)
self.setViewControllers(tabbarControllers, animated: true)
homeVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Home"), selectedImage: UIImage(named : "Home"))
listVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "List"), selectedImage: UIImage(named : "List"))
notificationVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Notification"), selectedImage: UIImage(named : "Notification"))
settingVC.tabBarItem = UITabBarItem(title: "", image: UIImage(named : "Setting"), selectedImage: UIImage(named : "Setting"))
UITabBar.appearance().tintColor = ColorConstants.ThemeColor
homeVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
listVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
notificationVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
settingVC.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
if #available(iOS 10.0, *) {
UITabBar.appearance().unselectedItemTintColor = ColorConstants.BlackColor
} else {
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: ColorConstants.BlackColor], for: .normal)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setupTabBarSeparators() {
let itemWidth = floor(self.tabBar.frame.size.width / CGFloat(self.tabBar.items!.count))
// this is the separator width. 0.5px matches the line at the top of the tab bar
let separatorWidth: CGFloat = 0.5
// iterate through the items in the Tab Bar, except the last one
for i in 0...(self.tabBar.items!.count - 1) {
// make a new separator at the end of each tab bar item
let separator = UIView(frame: CGRect(x: itemWidth * CGFloat(i + 1) - CGFloat(separatorWidth / 2) , y: 15, width: CGFloat(separatorWidth), height: self.tabBar.frame.size.height - 30))
// set the color to light gray (default line color for tab bar)
separator.backgroundColor = UIColor.lightGray
self.tabBar.addSubview(separator)
}
}
override func viewWillAppear(_ animated : Bool){
super.viewWillAppear(true)
setupTabBarSeparators()
}
}
ios swift uiviewcontroller uitabbarcontroller tabbar
ios swift uiviewcontroller uitabbarcontroller tabbar
edited Nov 25 '18 at 8:36
Jitendra Modi
asked Nov 25 '18 at 7:33
Jitendra ModiJitendra Modi
1,605724
1,605724
I think your problem is in the view controllers. share the HomeVC code.
– Tal Cohen
Nov 25 '18 at 8:33
It's much code to look at :) Try to use View Hierarchy Debugger to debug your view and understand which one is causing the problem. or try to isolate the problem in some other way and ask a more specific question.
– Tal Cohen
Nov 25 '18 at 8:45
Did you tryextendedLayoutIncludesOpaqueBars
andautomaticallyAdjustsScrollViewInsets
?
– Geru
Nov 25 '18 at 9:06
No, Please tell me more about it
– Jitendra Modi
Nov 26 '18 at 7:39
add a comment |
I think your problem is in the view controllers. share the HomeVC code.
– Tal Cohen
Nov 25 '18 at 8:33
It's much code to look at :) Try to use View Hierarchy Debugger to debug your view and understand which one is causing the problem. or try to isolate the problem in some other way and ask a more specific question.
– Tal Cohen
Nov 25 '18 at 8:45
Did you tryextendedLayoutIncludesOpaqueBars
andautomaticallyAdjustsScrollViewInsets
?
– Geru
Nov 25 '18 at 9:06
No, Please tell me more about it
– Jitendra Modi
Nov 26 '18 at 7:39
I think your problem is in the view controllers. share the HomeVC code.
– Tal Cohen
Nov 25 '18 at 8:33
I think your problem is in the view controllers. share the HomeVC code.
– Tal Cohen
Nov 25 '18 at 8:33
It's much code to look at :) Try to use View Hierarchy Debugger to debug your view and understand which one is causing the problem. or try to isolate the problem in some other way and ask a more specific question.
– Tal Cohen
Nov 25 '18 at 8:45
It's much code to look at :) Try to use View Hierarchy Debugger to debug your view and understand which one is causing the problem. or try to isolate the problem in some other way and ask a more specific question.
– Tal Cohen
Nov 25 '18 at 8:45
Did you try
extendedLayoutIncludesOpaqueBars
and automaticallyAdjustsScrollViewInsets
?– Geru
Nov 25 '18 at 9:06
Did you try
extendedLayoutIncludesOpaqueBars
and automaticallyAdjustsScrollViewInsets
?– Geru
Nov 25 '18 at 9:06
No, Please tell me more about it
– Jitendra Modi
Nov 26 '18 at 7:39
No, Please tell me more about it
– Jitendra Modi
Nov 26 '18 at 7:39
add a comment |
0
active
oldest
votes
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%2f53465531%2ftabbar-controller-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53465531%2ftabbar-controller-issue%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
I think your problem is in the view controllers. share the HomeVC code.
– Tal Cohen
Nov 25 '18 at 8:33
It's much code to look at :) Try to use View Hierarchy Debugger to debug your view and understand which one is causing the problem. or try to isolate the problem in some other way and ask a more specific question.
– Tal Cohen
Nov 25 '18 at 8:45
Did you try
extendedLayoutIncludesOpaqueBars
andautomaticallyAdjustsScrollViewInsets
?– Geru
Nov 25 '18 at 9:06
No, Please tell me more about it
– Jitendra Modi
Nov 26 '18 at 7:39