0

我在视图控制器上使用标签栏控制器而不是委托,并使用下面提到的代码。

tabController = [[UITabBarController alloc]init];
tabController.delegate = self;

scanView = [[ScanTicketView alloc] init];
searchView = [[SearchView alloc] init];
historyView = [[HistoryView alloc]init];

tabController.viewControllers=[NSArray arrayWithObjects:scanView,searchView,historyView, nil];

[self.navigationController pushViewController:tabController animated:YES];

它有效,但现在如何将图像应用于这些视图。有人能帮我一下吗。

提前致谢。

4

2 回答 2

1

Tabbar 控制器有自己的 Image 和 Title 属性。

仔细阅读此UITabbar 教程以正确理解。您可以通过属性窗口甚至通过编码设置图像。

好运 !

于 2012-09-26T11:50:41.753 回答
1

您可以使用:

 viewController.tabBarItem.image = [UIImage imageNamed:@"imageName.png"];

如果您只想将图像应用于选项卡栏中的选定视图控制器,则 UITabBarController 有一个 selectedViewController 和一个 selectedIndex 属性,如果这可能有帮助,请参见 tabBarController.tabBar.selectedItem.tag。

于 2012-09-26T11:50:42.747 回答