2014-09-01 27 views
14

,我發現了以下錯誤:的Xcode 6 Beta版6 CUICatalog:無效的資產名稱提供:(空)或無效的比例係數:2.000000

CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000 
Could not load the "(null)" image referenced from a nib in the bundle with identifier "com.example.project" 

我越來越的錯誤,因爲我樹立了「選擇圖片」以Interface Builder的一個標籤欄項目:

enter image description here

我已經添加文件到Xcode中:

enter image description here

設置寫入文件的故事板:

<tabBarItem key="tabBarItem" title="..." image="config.png" selectedImage="config_filled.png" id="5Wh-7m-Y4H"/> 

我使用的Xcode 6測試版6

我知道Error: CUICatalog: Invalid asset name supplied: (null), or invalid scale factor : 2.000000但是這並不能幫助我。

什麼可能導致資產名稱爲空?我已經重新進入了圖像名稱,我也嘗試了清理和重建,但錯誤仍然存​​在(並且沒有出現圖像)

+0

UIImageView再次選擇圖像我收到完全相同的錯誤,並沒有提到一個無效的比例因子。我正在使用提供了所有圖像大小的資產目錄。這似乎是一個明確的錯誤。我的最終解決方案是簡單地排除選定的圖像,因爲我沒有看到它值得進一步追求。 – 2014-10-18 00:42:14

+1

Duplicate from http://stackoverflow.com/questions/12672603/could-not-load-the-image-referenced-from-a-nib 答案就在那裏。 – 2014-10-31 19:02:08

+0

@GabrielCartier請仔細閱讀我的問題,我已經檢查過,當我問我的問題。 – idmean 2014-10-31 19:04:32

回答

-2

嘗試關閉「.png」擴展名,這將會修復某些IB圖像加載問題過去。

+2

沒有幫助,我仍然得到相同的錯誤。 – idmean 2014-09-02 06:59:07

18

我終於結束了在AppDelegate中使用這個討厭的代碼:

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; 
((UITabBarItem *)tabBarController.tabBar.items[0]).selectedImage = [UIImage imageNamed:@"light_filled"]; 
((UITabBarItem *)tabBarController.tabBar.items[1]).selectedImage = [UIImage imageNamed:@"umbrella_filled"]; 
((UITabBarItem *)tabBarController.tabBar.items[2]).selectedImage = [UIImage imageNamed:@"config_filled"]; 

希望蘋果公司將盡快修復這個bug。

+3

Xcode 6.1已經出來,錯誤仍然存​​在。 :( – 2014-10-27 11:09:41

+0

@RudolfAdamkovic是啊,我知道了。奇怪的是,蘋果並沒有注意到/修復這個bug。 – idmean 2014-10-27 11:10:18

+0

整個事情幾乎沒有工作,只是當我實現您的解決方案,代碼完成斯威夫特停止工作。無可奉告。 – 2014-10-27 11:16:21

29

在Xcode 6.1中,屬性檢查器中的某些屬性不起作用,但可以使用「用戶定義的運行屬性」來解決此問題。

我解決這個問題是這樣的: enter image description here

+2

我試過這個解決方案,並在我的具體情況,它的工作原理。謝謝,@mistyhua。 – enreas 2014-12-23 13:20:30

+0

這是天才。這裏有一個給予好評。 – 2015-01-24 02:07:34

+0

完美的作品。我有我的圖片在.xcassets文件。 – Daniel 2015-02-19 15:21:22

-1

我因爲缺乏代碼完成迅速的解決方法是這樣的

let secondItem = tabBarController.tabBar.items![1] as UITabBarItem 
    secondItem.selectedImage = UIImage(named: "home-selected") 

這是擺在AppDelegate中的didFinishLaunchingWithOptions。

5

保留界面生成器中的選項欄欄的「選定圖像」爲空應該刪除警告消息。

+0

但是,我仍然沒有選擇的圖像? – idmean 2015-03-30 06:30:32

+2

不知何故,這裏選擇的圖像不適用於我的應用程序。使其工作的唯一方法是使用「用戶定義的運行時屬性」,就像上面一樣。 – NEO 2015-03-31 06:27:07

+0

所以請在上面發表評論。這個答案本身就很沒用。 – idmean 2015-03-31 06:30:31

0

我找到的解決方案是的TabBar圖像的Images.xcassets的項設置爲渲染爲:模板圖像

這解決了錯誤和警告。

信用轉到this answer從另一個問題。

+0

這聽起來合乎邏輯的。我會盡力的。 – idmean 2015-05-16 21:08:35

1

對我來說,解決辦法是檢查所有UIImageViews的故事,有時,如果你刪除UIImageview,並用CMD + Z恢復它們,在UIImageView圖像變得"Unknown"。我認爲這是一個錯誤,因爲你仍然可以在故事板中看到圖像。

解決方案:在故事板

+0

感謝!當我檢查的UIImageView,它顯示有** **未知現在我刪除和做工精細。 – 2016-12-22 07:33:17

相關問題