2013-03-08 2 views
1

iOS 5.1 및 iOS 6.1에서 내 응용 프로그램이 완벽하게 실행됩니다. 그러나 wheen는 나는이 코드에 crahing 것보다 아이폰 OS 4.3에서 실행하려고 : 내가 TabBar의에 이미지 최저치를이 코드를 사용하고시뮬레이터에서 iOS 4.3을 실행하면 응용 프로그램이 충돌합니다.

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"home-normal"]]; 

.

이것은 내 로그 정보입니다. 좋아

2013-03-08 15:16:27.688 GrandNatural[3372:12c03] -[UITabBarItem setFinishedSelectedImage:withFinishedUnselectedImage:]: unrecognized selector sent to instance 0x628c090 
2013-03-08 15:16:27.690 GrandNatural[3372:12c03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarItem setFinishedSelectedImage:withFinishedUnselectedImage:]: unrecognized selector sent to instance 0x628c090' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x019785a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x016e7313 objc_exception_throw + 44 
    2 CoreFoundation      0x0197a0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x018e9966 ___forwarding___ + 966 
    4 CoreFoundation      0x018e9522 _CF_forwarding_prep_0 + 50 
    5 GrandNatural      0x0000f8fe -[HomeViewController initWithNibName:bundle:] + 535 
    6 GrandNatural      0x00002985 -[GrandNaturalAppDelegate application:didFinishLaunchingWithOptions:] + 262 
    7 UIKit        0x00ce5c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 
    8 UIKit        0x00ce7d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439 
    9 UIKit        0x00cf2617 -[UIApplication handleEvent:withNewEvent:] + 1533 
    10 UIKit        0x00ceaabf -[UIApplication sendEvent:] + 71 
    11 UIKit        0x00ceff2e _UIApplicationHandleEvent + 7576 
    12 GraphicsServices     0x021dd992 PurpleEventCallback + 1550 
    13 CoreFoundation      0x01959944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    14 CoreFoundation      0x018b9cf7 __CFRunLoopDoSource1 + 215 
    15 CoreFoundation      0x018b6f83 __CFRunLoopRun + 979 
    16 CoreFoundation      0x018b6840 CFRunLoopRunSpecific + 208 
    17 CoreFoundation      0x018b6761 CFRunLoopRunInMode + 97 
    18 UIKit        0x00ce77d2 -[UIApplication _run] + 623 
    19 UIKit        0x00cf3c93 UIApplicationMain + 1160 
    20 GrandNatural      0x00002856 main + 132 
    21 GrandNatural      0x00002795 start + 53 
) 
terminate called throwing an exception(lldb) 
+0

그것을 덤프 말한다처럼. API의 버전 5에서 소개 된 setFinishedSelectImage 메소드를 인식하지 못합니다. 코드에서 수행 할 수있는 작업은 SELECTORS를 사용하는 것이며 구체적으로 respondsToSelector를 사용하여 객체에 사용 가능한 메서드가 있는지 확인합니다. – Bushbert

+0

다음을 확인하십시오. -http : //stackoverflow.com/questions/8939399/tabbar-item-image-and-selectedimage –

답변

3

이 코드를 사용하여 TabBar의에 이미지를 설정할 수 있습니다

if ([[[UIDevice currentDevice] systemVersion] floatValue]<5.0) 
{ 
    self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"your name" image:[UIImage imageNamed:@"home-normal"] tag:0]; 
} 
else 
{ 
    self.tabBarItem = [[UITabBarItem alloc] init]; 
    self.tabBarItem.title = @"your name"; 
    [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home-active"] withFinishedUnselectedImage:[UIImage imageNamed:@"home-normal"]]; 
} 
+0

고맙습니다. 제게 많은 도움이됩니다. –

2

UITabBarItemdocumentation page로 이동하는 방법을 발견하고 가용성

에서 나는 당신에게 힌트를주지 말씀을 말해 : 4.3 유효하지 않습니다.

+0

오 예, "사용 가능 : iOS 5.0 이상에서 사용 가능합니다." 당신이 나를 도울 수있는 방법에 대한 자세한 내용은 iOS 4.3 –

+0

여기를보십시오. http://stackoverflow.com/questions/13245898/tabbar-customization-in-ios-4 – Bushbert

+0

하지만 그 코드를 사용하려면 먼저 내 os가 os 탐지에 대한 제안을 실행 중임을 감지해야합니다. –