2009-05-04 6 views
0

인터페이스 컨트롤러에 UITabBarController에 뷰 컨트롤러가 추가되었습니다. 프로그래밍 방식으로 그림을 추가하고 항목 제목을 변경하려면 어떻게합니까?UITabBar에 그림 추가

답변

3

appDelegate.m 파일의 'applicationDidFinishLaunching :'함수에 추가 할 수 있습니다. 예를 들어

:

NSInteger index = 0; 
while(index < 4){ // 4 is the number of tabbar items 
    UINavigationController *navCtrlr = (UINavigationController*)[[tabBarController viewControllers] objectAtIndex:index]; 
    UITabBarItem *tabBar = (UITabBarItem *) navCtrlr.tabBarItem; 
    if(index == 0){ 
     tabBar.image = [UIImage imageNamed:@"home-item.png"]; 
     tabBar.title = @"home"; 
    } 
    ... 
    index ++; 
} 
관련 문제