如何使用一个UITabbarItem添加UITabBar作为按钮?

时间:2013-08-03 09:17:36

标签: ios uitabbarcontroller uitabbar uitabbaritem

I want something like looking in image, I want to do this in tabbar application or mainstoryboard. This i did normal single view based application with tabbar item.

我想要查看图片,我想在tabbar应用程序或mainstoryboard中执行此操作。我使用tabbar项目进行了普通的基于单一视图的应用程序。

我也尝试使用代码,在此单击tabbar项时,特定的viewcontroller会打开。但我想点击第三个tabbar项目它应该显示UIActionSheet而不是第三个viewcontroller。我怎么能做到这一点。

FisrtTabViewController  *first = [[FisrtTabViewController alloc]initWithNibName:@"FisrtTabViewController" bundle:nil];
[first.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"myarea_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"myarea.png"]];

UINavigationController *tabItem1 = [[UINavigationController alloc] initWithRootViewController: first];    

SecconTabViewController  *second = [[SecconTabViewController alloc] initWithNibName:@"SecconTabViewController" bundle:nil];

[ second.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"areaconv_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"areaconv.png"]];

ThirdTabViewController  *third = [[ThirdTabViewController alloc] initWithNibName:@"ThirdTabViewController" bundle:nil];
[ third.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"share_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"share.png"]];

tabbar1.viewControllers = [NSArray arrayWithObjects:tabItem1,second,third,nil];

[[UITabBar appearance]setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected.png"]];

tabbar1.modalTransitionStyle =UIModalTransitionStyleCrossDissolve;

[self presentViewController:tabbar1 animated:YES completion:NULL];

提前致谢。

0 个答案:

没有答案