尽我所能,我无法使它正常工作.这是我最近的尝试.有人可以告诉我为什么这行不通吗?
Try as I might, I cannot get this to work. Here is my latest attempt. Can someone clue me in as to why this does not work?
在我的视图控制器的init方法调用的方法中:
In a method which is called by my view controller's init method:
UIImage *image = [UIImage imageNamed: @"window22.png"]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"Some Title" image: image tag: 0]; self.tabBarItem = item;它所做的只是在应该放置图像的地方放一个大正方形.标签栏中的标题与视图控制器的标题相同.
All it does is put a big square where the image should be. The title in the tab bar remains the same as the view controller's title.
这里所有的内容都以编程方式实例化,包括标签栏控制器.
Everything is being instantiated programmatically here, including the tab bar controller.
推荐答案根据文档,tabBarItem将自动实例化-您无需自己创建它.当我在tabBar中为视图控制器设置标题和图像时,我就使用了
According to the docs, the tabBarItem will be instantiated automatically- you don't need to create it yourself. When I've set the title and image in the tabBar for a view controller, I've used
self.tabBarItem.image = [UIImage imageNamed:imageName];更多推荐
iPhone以编程方式实例化UITabBarItem
发布评论