2012-03-13 3 views
4

外部バンドルにある画像へのアクセス、私はfiles.Thisの支援にバンドルを置き、私は上の画像を表示することができません。ここに私のコード私は名前applausible.bundleのバンドルを作成し

NSBundle* myBundle; 
myBundle = [NSBundle bundleWithPath:@"/Library/applausible.bundle"]; 
NSString *path = [myBundle pathForResource:@"splash.png" ofType:nil]; 
[imageName setImage:[UIImage imageNamed:path]]; 

ですイメージビュー。私がこのようにしたもう一つの方法は、アプリケーションを実行しながら、xibを使ってイメージビューにイメージを置きます。コンソールの出力が次のようになります 識別子が "com.xxxxxxx.ImageSample"のバンドルのペン先から参照される "splash_screen high resolution.png"イメージを読み込めませんでした。私は間違いをどこにしたか教えてもらえますか?私の目標は、外部バンドルにあるUIImageviewに画像を表示することです。

+0

あなたの質問は判読可能な形式で書式を設定してください。 –

+0

ログstmtを の隣に置きます。NSString * bundlePath = [[NSBundle mainBundle] pathForResource:@ "applausible" ofType:@ "Bundle"]; .... – iDroid

+0

バンドルパスは完全に表示されていますが、画像パスがヌルです – siva

答えて

6

二行目からあなたのコードを使用して、バンドルを取得することができ、この方法を使用して

NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"applausible" ofType:@"Bundle"]; 

役に立つかもしれません。

NSString bundlePath = [[NSBundle mainBundle] pathForResource:@"applausible" ofType:@"Bundle"]; 
NSLog(@"Bundle path is %@",bundlePath); 
NSBundle myBundle; 
myBundle = [NSBundle bundleWithPath:bundlePath]; 
NSString *path = [myBundle pathForResource:@"splash_screen high resolution" ofType:@"png"]; 
UIImage *image=[[UIImage alloc]initWithContentsOfFile:path]; 
[imageName setImage:image]; 

試してみてください。

+0

ありがとうございます – siva

0

それはあなたがpath.Thenこれはあなたを助けるかもしれ

myBundle = [NSBundle bundleWithPath:bundlePath]; 
NSString *path = [myBundle pathForResource:@"splash" ofType:[email protected]"png"]; 
[imageName setImage:[UIImage imageNamed:path]]; 
+0

ありがとうございます。私はあなたが上で述べたものを試しましたが、それは結果を得ていません。 – siva

関連する問題