我试图以编程方式添加UITabBarController
。一切工作正常,但我有两个问题。UITabBarController背景图像设置不正确
但它显示了在底部另一个这样的绿线:
这里是我的代码使用用于此:
[self.myTabBarController.tabBar setBackgroundImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar.png" ofType:nil]]];
的另一个问题是,我使用这个代码设置的TabBar项目图片:
MyViewController *myController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; UINavigationController *myNavController = [[UINavigationController alloc] initWithRootViewController: myController]; [myNavController.tabBarItem initWithTitle:@"" image:[UIImage imageNamed:@"ads_inactive.png"] selectedImage:[UIImage imageNamed:@"ads_active.png"]];
图像设置,但是当我尝试使用添加在MyViewController
的viewDidLoad
标题是:
self.title = @"My Ads";
它在tabbar项目上也显示相同的标题,但我不想在那里有任何标题。
我该如何解决这个问题? 由于
有一个修复这是我使用的,但问题是,它将要求子类UIViewController并使用此子类作为您的Tabbar的naivgationcontrollers中的所有视图控制器的父类,如果这不是你以前做过的事情,那是使用子类的子类,那么它只会让你感到困惑,但是这可以解决标题问题,除非yoiu正确,否则这个问题会困扰你。 – Loxx
如果听起来你可以处理这个,那么我可以帮忙,但它的代码很多 – Loxx