2014-03-13 5 views
0

탭바에 이미지를 추가하고 있습니다. iamge 크기는 49px입니다. 추가가 정상적으로 작동합니다. 그러나 레이아웃에 문제가 있습니다. 모든 탭바의 아이템 이미지의 윗부분은 탭바의 프레임에서 벗어 났고, 아래쪽에는 충분한 공간이 있습니다.Tabbar 항목 이미지 문제

해결 방법? 내가 다시 일 같은 문제의 몇 가지를 가지고와이 ..

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
    { 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 

     [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"navHomeHL.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"navHome.png"]]; 

     } } 

     return self; 
     } 

enter image description here

답변

0

이 시도 -

내가

 localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:3]; 


     myhomeVC = [[EventListView alloc] initWithNibName:@"EventListView_iPhone" bundle:nil]; 
     homeNavBar=[[UINavigationController alloc]initWithRootViewController:myhomeVC]; 
     homeNavBar.tabBarItem.title=nil; 



     groupVC = [[ItineryView alloc] initWithNibName:@"ItineryView_iPhone" bundle:nil]; 
     groupNavBar=[[UINavigationController alloc]initWithRootViewController:groupVC]; 
     //[email protected]""; 



     uploadVC = [[FilesView alloc] initWithNibName:@"FilesView_iPhone" bundle:nil]; 
     uploadNavBar=[[UINavigationController alloc]initWithRootViewController:uploadVC]; 
     //[email protected]""; 

     searchVC = [[PhotosView alloc] initWithNibName:@"PhotosView_iPhone" bundle:nil]; 
     searchNavBar=[[UINavigationController alloc]initWithRootViewController:searchVC]; 
     //[email protected]""; 

     nearbyVC = [[AttendeesView alloc] initWithNibName:@"AttendeesView_iPhone" bundle:nil]; 
     nearbyNavBar=[[UINavigationController alloc]initWithRootViewController:nearbyVC]; 
     //[email protected]""; 



     [localViewControllersArray addObject:homeNavBar]; 
     [localViewControllersArray addObject:groupNavBar]; 
     [localViewControllersArray addObject:uploadNavBar]; 
     [localViewControllersArray addObject:searchNavBar]; 
     [localViewControllersArray addObject:nearbyNavBar]; 



     appDelegate.tabBarController.viewControllers = localViewControllersArray; 
     [self.parentViewController.view setHidden:YES]; 

     appDelegate.window.rootViewController = appDelegate.tabBarController; 

및 설정 TabBar의 항목과 같이 TabBar의를 생성하는 방법이다 코드가 그것을 고쳤습니다.

UIViewController *viewController1, *viewController2,*viewController3; 
viewController1 = [[ViewController alloc] init]; 
viewController2 = [[FormStatusViewController alloc] initWithNibName:@"FormStatusViewController" bundle:nil]; 
viewController3 = [[DocumentsViewController alloc] init]; 

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController1]; 
UINavigationController *nav1 =[[UINavigationController alloc] initWithRootViewController:viewController2]; 
UINavigationController *nav2 =[[UINavigationController alloc] initWithRootViewController:viewController3]; 

nav.navigationBarHidden=YES; 
nav1.navigationBarHidden=YES; 
nav2.navigationBarHidden=YES; 

NSArray *viewsArray = [[NSArray alloc] initWithObjects:nav,nav1,nav2, nil]; 
self.formTabBar= [[UITabBarController alloc] init]; 
[self.formTabBar setViewControllers:viewsArray]; 

UITabBar *tabBar = self.formTabBar.tabBar; 
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0]; 
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1]; 
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2]; 

tabBarItem1.title = @"FORM"; 
tabBarItem2.title = @"STATUS"; 
tabBarItem3.title = @"DOCUMENTS"; 

UIImage *tabBackground = [[UIImage imageNamed:@"tab_bg.png"] 
          resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; 
[[UITabBar appearance] setBackgroundImage:tabBackground]; 

if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7) { 
    [tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"form.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"form_h.png"]]; 
    [tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"status.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"status_h.png"]]; 
    [tabBarItem3 setFinishedSelectedImage:[UIImage imageNamed:@"documents.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"documents_h.png"]]; 
} else { 
    tabBarItem1.selectedImage = [[UIImage imageNamed:@"form_h.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 
    tabBarItem1.image = [[UIImage imageNamed:@"form.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 

    tabBarItem2.selectedImage = [[UIImage imageNamed:@"status_h.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 
    tabBarItem2.image = [[UIImage imageNamed:@"status.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 

    tabBarItem3.selectedImage = [[UIImage imageNamed:@"documents_h.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 
    tabBarItem3.image = [[UIImage imageNamed:@"documents.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 


} 
[[UITabBar appearance] setSelectionIndicatorImage: 
[UIImage imageNamed:@"tab_select_indicator.png"]]; 
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                [UIColor whiteColor], UITextAttributeTextColor,nil] forState:UIControlStateNormal]; 

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                [UIColor whiteColor], UITextAttributeTextColor,nil] forState:UIControlStateHighlighted]; 

희망이 당신에게

+0

도움이 될 것 더 같은 문제가 없습니다 occurs..there있는 모든 탭 표시 줄 항목 아래 공간 –

관련 문제