Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在模拟器的iOS 4.3上运行时,应用程序将崩溃_Iphone_Ios_Uitabbaritem - Fatal编程技术网

Iphone 在模拟器的iOS 4.3上运行时,应用程序将崩溃

Iphone 在模拟器的iOS 4.3上运行时,应用程序将崩溃,iphone,ios,uitabbaritem,Iphone,Ios,Uitabbaritem,我的应用程序在iOS 5.1和iOS 6.1中运行完美。但当我试图在iOS 4.3上运行它时,它却在这段代码上崩溃了: [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"home-normal"]]; 我用这段代码在TabBar上设置图像 这是我的日志信息 2013-03-08 1

我的应用程序在iOS 5.1和iOS 6.1中运行完美。但当我试图在iOS 4.3上运行它时,它却在这段代码上崩溃了:

 [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"home-normal"]];
我用这段代码在TabBar上设置图像

这是我的日志信息

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) 
好的,转到for
uitabaritem
,找到该方法,并告诉我它在可用性下的说明

我将给您一个提示:4.3无效。

好的,转到for
uitabaritem
,找到该方法,并告诉我它在可用性下的说明


我给您一个提示:4.3无效。

您可以使用以下代码在选项卡栏上设置图像:

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"]];
}

如果([[[UIDevice currentDevice]systemVersion]floatValue]您可以使用以下代码在选项卡栏上设置图像:

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"]];
}

if([[[UIDevice currentDevice]systemVersion]floatValue]它就像转储所说的那样。它无法识别setFinishedSelectImage方法,因为它是在API第5版中引入的。您可以在代码中使用选择器,并专门响应选择器,以查看对象是否具有可用的方法。检查此项:-它就像转储所说的那样。它无法识别setFinishedSelectImage方法它是在API的第5版中引入的。您可以在代码中使用选择器,特别是响应选择器,以查看对象是否具有可用的方法。请检查:-哦,是的,它显示“可用性:在iOS 5.0及更高版本中可用”那么,你能不能帮我看看如何在iOS 4.3上实现这一点?请看这里。但是要使用这些代码,我必须首先检测我应用程序上的哪个操作系统正在运行操作系统检测建议做你的功课,这个问题在堆栈溢出时已经被回答了很多次。我能不能限制我的应用程序在第三代移动设备上使用,并且只能在iOS>5.0上工作?哦,是的,上面写着“可用性:在iOS 5.0及更高版本中可用。”那么,你能不能帮我看看如何在iOS 4.3上实现这一点?请看这里。但是要使用这些代码,我必须首先检测我应用程序上的哪个操作系统正在运行操作系统检测建议做你的功课,这个问题在堆栈溢出时已经被回答了很多次。我能不能限制我的应用程序在第三代移动设备上使用,并且只能在iOS>5.0上工作?