我有一段简单的代码,可以在选项卡上放置一个背景图像。
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabBG.png"]];
[self.tabBarController.tabBar insertSubview:imageView atIndex:0];
[imageView release];
这在iOS 4中运行良好,但在iOS 5中测试时无法工作。
我正在尝试做以下事情:
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabBG.png"]];
NSString *reqSysVer = @"4.3";
NSString *iOSVersion = [[UIDevice currentDevice] systemVersion];
if ([iOSVersion compare:reqSysVer options:NSNumericSearch] !=NSOrderedDescending) {
// code for iOS 4.3 or below
[self.tabBarController.tabBar insertSubView:imageView atIndex:0];
}
else {
// code for iOS 5
[self.tabBarController.tabBar insertSubView:imageView atIndex:1];
}
[imageView release];
哎呀,这个方法不起作用了...有人能提供解决方案吗?