2014-03-13 1 views
2

iOS 7.1 업데이트 후 tabBar의 이미지를 볼 수 없지만 하나의 이미지를 클릭하면 나타납니다. 나는 문제를 검색하고 내가 selectedImage를 추가해야합니다 것을 발견iOS 7.1로 업데이트 한 후 tabBar 이미지가 사라졌습니다.

UINavigationController* myController; 

.. //some code here 

myController.tabBarItem.image = [UIImage imageNamed:@"someImage.png"]; 
myController.navigationBar.barTintColor = myColor; 
myController.navigationBar.translucent = NO; 

//and so on for the remaining controllers, then I add them to the tabBarController 

한 tabBar 항목의 이미지를 설정하려면 다음 코드를했습니다하지만

myController.tabBarItem.selectedImage = [UIImage imageNamed:@"someImage.png"]; 

어떤 생각을 작동하지 않았다?

나는 문제가 내 대답

+0

당신이 정확한 철자와 정확한 경우에, 확인 했 이미지 파일 이름에? – Gallymon

+0

예, 이미 iOS 7.1 이상에서 작동하지만 iOS 7.1로 업데이트 한 후 사라졌습니다. – Sawsan

+0

"문제를 검색 한 결과 selectedImage를 추가해야하지만 작동하지 않았습니다." 그래서 7.0에서 요구되지 않은 7.1에서 필요한 것을 발견했다고 생각하니? – Gallymon

답변

2

나는 다음에 내 코드를 업데이트 지금 작동을 확인 고정. imageWithRenderingMode을 사용하여 문제를 해결했습니다.

//This is the line that I updated 
myController.tabBarItem.image = [[UIImage imageNamed:@"someImage.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]; 

//And added this line too, I used the same original image not new one for the selected case 
myController.tabBarItem.selectedImage = [UIImage imageNamed:@"someImage.png"]; 

//The rest of code is the same 

다음과 같은 네비게이션 컨트롤러를 정의 이상의 barItem의 경우를 들어

, UPDATE :

UINavigationController* firstNavigationController; 
UINavigationController* secondNavigationController; 
UINavigationController* thirdNavigationController; 

firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController]; 
firstNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 

secondNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController]; 
secondNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage2.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 

thirdNavigationController = [[UINavigationController alloc] initWithRootViewController:thirdViewController]; 
thirdNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
이미지를 추가 할 때
+0

하나의 바 항목에 3 개의 막대 항목이있는 경우에는 어떻게됩니까? – Sumitiscreative

+0

@Sumitiscreative 답변을 업데이트했습니다. – Sawsan