我正在爲iPhone 4和iPhone 5兼容應用程序。對於設置圖像我使用的代碼: [UIColor colorWithPatternImage: [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aaaa" ofType:@"png"]]]
imageWithContentsOfFile不適用於iPhone 5
它工作正常的iPhone 4模擬器和設備,但iPhone5的模擬器不起作用。我還沒有iPhone 5。任何機構都可以告訴我,它可以在iPhone 5設備上工作嗎?
如果我爲iPhone 5使用的圖像使用了不同的名稱,並且我不能使用圖像名稱寫@ 2x,那麼
[UIColor colorWithPatternImage: [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aaaa" ofType:@"png"]]]
可以很好地工作在onphone 5模擬器上。任何機構都可以告訴我,它是否也適用於iPhone 5設備?或者是否有任何其他出路使用
[UIColor colorWithPatternImage: [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aaaa" ofType:@"png"]]]
在iPhone 5上設置圖像。
請建議。
謝謝。
只是嘗試打印資源路徑[一個NSBundle mainBundle] pathForResource:@ 「AAAA」 ofType:@ 「PNG」],並確保它不是零 – prasad 2013-03-08 15:25:29
其打印路徑。適用於iPhone 4.如果我在代碼中將圖像名稱寫爲[email protected],則適用於iPhone 5。 – NiKKi 2013-03-11 07:39:11