2013-07-31 73 views
0

其他解决方案,用于将6个标签也是可接受在应用和标签栏的第二视图插入标签栏包含多于5个标签

至于超过5个标签我已经使用CiExpandableTabBarController 问题是: 如果我添加CiExpandableTabBarController像这样: self.window.rootViewController = CiExpandableTabBarController; 那么就没有问题..

,但我需要添加此为后第二种观点和看法.. 我的第一个观点是首次登录后如此,查看标签栏应该是可见的

现在我获得输出这样的:

选择tebbar不显示项目图像

enter image description here

enter image description here

但我想输出是这样的:

enter image description here

我已经添加标签栏所示:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 

[self makeTabBar]; 

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
//============== 


self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
// Override point for customization after application launch. 



if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
     self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; 
    } 
    else 
    { 
     self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_3" bundle:nil]; 
    } 

} else { 
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; 
} 

UINavigationController *nvc=[[UINavigationController alloc] initWithRootViewController:self.viewController]; 
self.window.rootViewController=nvc; 
[nvc setNavigationBarHidden:YES]; 
// self.window.rootViewController = self.viewController; 
[self.window makeKeyAndVisible]; 


return YES; 
} 

-(void)makeTabBar 
{ 
// self.tabBarController=[[UITabBarController alloc] init]; 
// self.tabBarController.customizableViewControllers = nil; 


ProductSearchViewController *homeObj; 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
     homeObj=[[ProductSearchViewController alloc] initWithNibName:@"ProductSearchViewController" bundle:nil]; 
    } 
    else 
    { 
     homeObj=[[ProductSearchViewController alloc] initWithNibName:@"ProductSearchViewController_3" bundle:nil]; 
    } 
} 
else 
{ 
    homeObj=[[ProductSearchViewController alloc] initWithNibName:@"ProductSearchViewController~ipad" bundle:nil]; 
} 
UINavigationController *tab1Controller = [[UINavigationController alloc] initWithRootViewController:homeObj]; 
[email protected]"Product Seach"; 
tab1Controller.tabBarItem.image=[UIImage imageNamed:@"productsearch.png"]; 

WhereToBuyViewController *chatListObj; 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
      chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController" bundle:nil]; 
    } 
    else 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController_3" bundle:nil]; 
    } 
} 
else 
{ 
    chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController~ipad" bundle:nil]; 
} 
UINavigationController *tab2Controller = [[UINavigationController alloc] initWithRootViewController:chatListObj]; 
[email protected]"Where To Buy"; 
tab2Controller.tabBarItem.image=[UIImage imageNamed:@"wheretobuy.png"]; 

//===========tab3 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController" bundle:nil]; 
    } 
    else 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController_3" bundle:nil]; 
    } 
} 
else 
{ 
    chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController~ipad" bundle:nil]; 
} 
UINavigationController *tab3Controller = [[UINavigationController alloc] initWithRootViewController:chatListObj]; 
[email protected]"Where To Buy"; 
tab3Controller.tabBarItem.image=[UIImage imageNamed:@"wheretobuy.png"]; 
//====================tab4 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController" bundle:nil]; 
    } 
    else 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController_3" bundle:nil]; 
    } 
} 
else 
{ 
    chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController~ipad" bundle:nil]; 
} 
UINavigationController *tab4Controller = [[UINavigationController alloc] initWithRootViewController:chatListObj]; 
[email protected]"Where To Buy"; 
tab4Controller.tabBarItem.image=[UIImage imageNamed:@"wheretobuy.png"]; 
//==============tabtab5 

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController" bundle:nil]; 
    } 
    else 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController_3" bundle:nil]; 
    } 
} 
else 
{ 
    chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController~ipad" bundle:nil]; 
} 
UINavigationController *tab5Controller = [[UINavigationController alloc] initWithRootViewController:chatListObj]; 
[email protected]"Where To Buy"; 
tab5Controller.tabBarItem.image=[UIImage imageNamed:@"wheretobuy.png"]; 
//=========================tab 6 

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    if([UIScreen mainScreen].bounds.size.height == 568) 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController" bundle:nil]; 
    } 
    else 
    { 
     chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController_3" bundle:nil]; 
    } 
} 
else 
{ 
    chatListObj=[[WhereToBuyViewController alloc] initWithNibName:@"WhereToBuyViewController~ipad" bundle:nil]; 
} 
UINavigationController *tab6Controller = [[UINavigationController alloc] initWithRootViewController:chatListObj]; 
[email protected]"Where To Buy"; 
tab2Controller.tabBarItem.image=[UIImage imageNamed:@"wheretobuy.png"]; 
//======================= 
CiExpandableTabBarController *tabbar=[[CiExpandableTabBarController alloc] initWithViewControllers:[NSArray arrayWithObjects:tab1Controller,tab2Controller,tab3Controller,tab4Controller,tab5Controller,tab6Controller, nil] andSelectedIndex:0]; 
[self.window addSubview:tabbar.view]; 
} 
+0

那么你的问题到底是什么? – logixologist

+0

有一个selectedBackgroundImage,只是设置它... – Horst

+0

没有这样的选项selectedBackgroundImage –

回答

0

对于选定的图像和UITabBarItem的未选择的图像,存在的两个属性它是finishedSelectedImagefinishedUnselectedImage。但是你根本无法设置这些属性,因为它们没有为它们定义任何setter方法,只是getter。

相反,你可以做这样的事情。假设'tab_1_unselImg'是您未选定的选项卡图像,'tab_1_selImg'用于选项卡栏控制器第一个选项卡的选定选项卡。

[[[[self.tabBarController viewControllers] objectAtIndex:0] tabBarItem] 
setFinishedSelectedImage:tab_1_selImg withFinishedUnselectedImage:tab_1_unselImg];