-1
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        CGSize result = [[UIScreen mainScreen] bounds].size;
            //NSLog(@"phonesize%@",result);
        if(result.height > 500){
                NSLog(@"iPhone 5");      
        }
        else{
                NSLog(@"iPhone 4");

            }
    }

私の Mac OS は 10.7.2 で Xcode 4.5.2 です。上記のコードを使用してデバイスが iPhone 4 または iPhone 5 であることを確認しました。iPhone5 を使用すると iPhone4 になります。起動イメージとアイコン イメージを設定しました。私が見逃したものは他にありますか?

4

4 に答える 4

0

テスト済みの代わりにこのコードを試してください。

if ([[UIDevice currentDevice] userInterfaceIdiom] ==UIUserInterfaceIdiomPhone)
    {
      //device is iPhone

      CGRect screenBounds = [[UIScreen mainScreen] bounds];
      if (screenBounds.size.height == 568) {
        //device is iphone 5
        //add storyboard/Xib that have large screen (320*568)
      } else {
          //device is iphone 4
          //add story board/Xib that have small screen (320*480)

      }

    }
else
    {
      //device is iPad
    }
于 2013-07-18T08:03:43.910 に答える
0

result画面のスケールに従って取得したものをスケーリングしてから確認する必要がありますscale...

 if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
        result = CGSizeMake(result.width * scale, result.height * scale);

        if(result.height == 960) {
            NSLog(@"iPhone 4");
        }
        if(result.height == 1136) {
            NSLog(@"iPhone 5");
        }
    }
    else{
        NSLog(@"Standard Resolution");
    }
}
于 2013-07-18T07:47:42.463 に答える
0
  if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
      CGRect screenBounds = [[UIScreen mainScreen] bounds];
      if (screenBounds.size.height == 568) 
      {
         //iphone 5

      else 
      {

        //iphone 4


      }
   }
else
    {
      //iPad
    }

これを試してみてください...

于 2013-07-18T08:06:38.057 に答える