无法更改UITabBarItem.image:CSI中不支持的像素格式

epi*_*ein 7 ios swift

我正在尝试通过代码更改标签栏中显示的图像.我目前正在使用Swift和Xcode 6 beta 3.我在Images.xcassets中导入了tabBarImage.png和tabBarImage@2x.png,在AppDelegate中我写了这个:

    func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {

    let mainColor = UIColor(red: 1.0, green: 91.0/255.0, blue: 84.0/255.0, alpha: 1.0)
    UITabBar.appearance().barTintColor = mainColor

    let tabBarController = self.window!.rootViewController as UITabBarController
    var tabBarSubcontrollers = tabBarController.viewControllers as [UIViewController]

    let tabBarImages = ["tabBarImageOne", "tabBarImageTwo", "tabBarImageThree"]

    for index in 0..<(tabBarSubcontrollers.count) {
        let tabBarImage = UIImage(named: "\(tabBarImages[index])").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        let newTabBarItem = UITabBarItem(title: "", image: tabBarImage, selectedImage: tabBarImage)
        newTabBarItem.imageInsets = UIEdgeInsetsMake(5.0, 0.0, -5.0, 0.0)
        tabBarSubcontrollers[index].tabBarItem = newTabBarItem
    }

    return true
}
Run Code Online (Sandbox Code Playgroud)

如果我在模拟器上运行它可以正常工作并在标签栏中显示图像.如果我在我的iPad(使用iOS 7.1.1)上运行它,它不会加载图像并显示这个奇怪的错误:

 Unsupported pixel format in CSI
 Unable to create unsliced image from csi bitmap data.
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?可能是某种bug吗?什么是CSI位图数据呢?

Chr*_*all 1

咕噜。

这似乎是 iOS 7 的问题。它适用于 iOS 8。

Beta 2 生成了 iOS 7 的东西;没问题。

Beta 3 似乎仅适用于 iOS 8。

我怀疑在 iOS 7 上尝试 Swift 的人都是 SOL

我有一个项目,我将上传到我的服务器,您可以随意修改。

更新: 这是测试项目

更新 2(2014 年 7 月 21 日):此错误似乎已在 Xcode 6 beta 4 中修复。

然而,Swift 似乎是一个相当快速移动的目标......

  • 在 iOS 7 中,使用普通的 Objective-C 也是一个问题。我很确定这是 beta 3 的问题 (2认同)