imageview用のフレームを元の画像サイズに設定して、それをビューの中心に表示しようとしています。私はこれに次のコードを書いていますが、画像はまだ画面全体に表示されています!画像のサイズが320x88で、320x460にサイズ変更されていると思われます。画面の中央に表示したいのでY座標を(460-88)/ 2に設定しますが、動作しません。誰でもこの問題を解決するのを助けてください。ありがとう。iPhone:画像を元のサイズに戻す
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:filePath]];
if(imageView.image.size.width == IPHONE4_RES_WIDTH)
[imageView setFrame: CGRectMake(0, 0, imageView.image.size.width/2, imageView.image.size.height/2)];
UIViewController *viewController = [[[UIViewController alloc] init] autorelease];
viewController.view.backgroundColor = [UIColor blackColor];
NSLog(@"%f : %f",viewController.view.bounds.size.height, imageView.bounds.size.height);
viewController.view = imageView;
viewController.view.contentMode = UIViewContentModeCenter;
[self.navigationController pushViewController:viewController animated:YES];
こんにちはラケッシュを、選択することができますが、それは何の違いもないようです!画像は画面中央に表示されますが、幅は640(iPhone4解像度)です!この問題に対処することはできますか?私の編集したコードを見てください。ありがとう。 – applefreak
また、私のビューの背景色が黒く表示されません! – applefreak
私は私の元の質問に基づいてあなたの答えを受け入れました。私はiPhone 4のサイズと背景色の問題を処理するコードを掲載しました!ありがとう。 – applefreak