-1

iPhone 6および6+でのみステータスバーを非表示にしようとしていますが、これはこれまで試したことです。

if (screenWidth == 375) {
        // Remove status bar for iPhone 6
        [[UIApplication sharedApplication] setStatusBarHidden:YES
                                                withAnimation:UIStatusBarAnimationFade];
    }else if (screenWidth == 414){
        // Remove status bar for iPhone 6 +
        [[UIApplication sharedApplication] setStatusBarHidden:YES
                                                withAnimation:UIStatusBarAnimationFade];
    }
4

5 に答える 5

0

viewDidLoad に次の行を追加します。

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

新しいメソッドを追加します

- (BOOL)prefersStatusBarHidden {
          return YES;
  }

info.plist ファイルも変更します

View controller-based status bar appearance" = NO

また、iPhone 6 および 6 Plus の条件も追加します。iPhone 6 および 6 Plus のメソッドは次のとおりです。

/*=====================================================================================================================
 Checks if the device has 4.7 inch screen such as iPhone6 generation
 =====================================================================================================================*/
+(BOOL) ISiPhone6
{
    BOOL isIpad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    // we need to check the maximum of width and height because some screens (the camera view while scanning) we can
    // rotate to portrait or landscape and in the case the screen height and width flip
    return (!isIpad && MAX(screenRect.size.height,screenRect.size.width) == 667);
}

/*=====================================================================================================================
 Checks if the device has 5.5 inch screen such as iPhone6 plus 
 =====================================================================================================================*/
+(BOOL) ISiPhone6Plus
{
    BOOL isIpad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    // we need to check the maximum of width and height because some screens (the camera view while scanning) we can
    // rotate to portrait or landscape and in the case the screen height and width flip
    return (!isIpad && MAX(screenRect.size.height,screenRect.size.width) == 736);
}  

それは私のために働く。

于 2015-09-09T11:33:53.507 に答える
0

iPhone 6 と iPhone 6 Plus でのみステータス バーを非表示にしたいだけなので、以下のようにできます。最初にこれをクラスに追加します。

   #import <sys/utsname.h> 

次に、viewDidLoad メソッドで

 NSString *platform;
struct utsname systemInfo;
uname(&systemInfo);
platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

if ( [platform  isEqual:@"iPhone6,1"]||[platform  isEqual:@"iPhone6,2"]){
[[UIApplication sharedApplication] setStatusBarHidden:YES
                                            withAnimation:UIStatusBarAnimationFade];
}
于 2015-09-09T11:41:07.147 に答える
0

あなたがすることができます(plistファイルを変更する):

set Status bar is initially hidden = YES

行を追加する:

View controller-based status bar appearance = NO
于 2015-09-09T11:24:57.643 に答える