[ios] Phonegap이있는 iOS 7 상태 표시 줄

iOS 7에서는 Phonegap 애플리케이션이 상태 표시 줄 아래에 나타납니다. 이로 인해 화면 상단에있는 버튼 / 메뉴를 클릭하기가 어려울 수 있습니다.

Phonegap 애플리케이션의 iOS 7에서이 상태 표시 줄 문제를 해결하는 방법을 아는 사람이 있습니까?

CSS로 전체 웹 페이지를 오프셋하려고 시도했지만 작동하지 않는 것 같습니다. 전체 UIWebView를 오프셋하거나 상태 표시 줄이 iOS6에서와 같이 동작하도록 만드는 방법이 있습니까?

감사



답변

다른 스레드에서 답변을 찾았지만 다른 사람이 궁금해 할 경우 질문에 답변하겠습니다.

그냥 교체 viewWillAppearMainViewController.m이와 :

- (void)viewWillAppear:(BOOL)animated {
    // View defaults to full size.  If you want to customize the view's size, or its subviews (e.g. webView),
    // you can do so here.
    // Lower screen 20px on ios 7
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
    }
    [super viewWillAppear:animated];
}


답변

Ludwig Kristoffersson의 크기 조정 수정 외에도 상태 표시 줄 색상을 변경하는 것이 좋습니다.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
    }
    self.view.backgroundColor = [UIColor blackColor];
}
-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}


답변

phonegap 용 플러그인을 설치하십시오 : https://build.phonegap.com/plugins/505

그리고 아래와 같이 올바른 설정을 사용하여 webview의 오버레이를 제어하십시오.

<preference name="StatusBarOverlaysWebView" value="false" />

나를 위해 Phonegap 3.3.0에서는 작동합니다.

자세한 내용은 Github 프로젝트 페이지 :
https://github.com/phonegap-build/StatusBarPlugin


답변

상태 표시 줄을 숨기려면 MainViewController.m함수 아래의 파일 에 다음 코드를 추가하십시오.-(void)viewDidUnload

- (BOOL)prefersStatusBarHidden
{
    return YES;
}


답변

답변 https://stackoverflow.com/a/19249775/1502287 이 저에게 효과적이지만 카메라 플러그인 (및 잠재적으로 다른 사용자)과 “height = device- 높이 “(높이 부분을 설정하지 않으면 내 경우에는 키보드가 뷰 위에 나타나고 도중에 일부 입력이 숨겨집니다).

카메라 뷰를 열고 앱으로 돌아갈 때마다 viewWillAppear 메서드가 호출되고 뷰가 20px만큼 축소됩니다.

또한 뷰포트의 장치 높이에는 20 픽셀의 추가 픽셀이 포함되어 콘텐츠를 스크롤 가능하고 웹뷰보다 20 픽셀 더 높게 렌더링합니다.

다음은 카메라 문제에 대한 완전한 솔루션입니다.

MainViewController.h에서 :

@interface MainViewController : CDVViewController
@property (atomic) BOOL viewSizeChanged;
@end

MainViewController.m에서 :

@implementation MainViewController

@synthesize viewSizeChanged;

[...]

- (id)init
{
    self = [super init];
    if (self) {
        // On init, size has not yet been changed
        self.viewSizeChanged = NO;
        // Uncomment to override the CDVCommandDelegateImpl used
        // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
        // Uncomment to override the CDVCommandQueue used
        // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
    }
    return self;
}

[...]

- (void)viewWillAppear:(BOOL)animated
{
    // View defaults to full size.  If you want to customize the view's size, or its subviews (e.g. webView),
    // you can do so here.
    // Lower screen 20px on ios 7 if not already done
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7 && !self.viewSizeChanged) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
        self.viewSizeChanged = YES;
    }
    [super viewWillAppear:animated];
}

이제 뷰포트 문제에 대해 deviceready 이벤트 리스너에 다음을 추가하십시오 (jQuery 사용).

if (window.device && parseFloat(window.device.version) >= 7) {
  $(window).on('orientationchange', function () {
      var orientation = parseInt(window.orientation, 10);
      // We now the width of the device is 320px for all iphones
      // Default height for landscape (remove the 20px statusbar)
      var height = 300;
      // Default width for portrait
      var width = 320;
      if (orientation !== -90 && orientation !== 90 ) {
        // Portrait height is that of the document minus the 20px of
        // the statusbar
        height = document.documentElement.clientHeight - 20;
      } else {
        // This one I found experimenting. It seems the clientHeight
        // property is wrongly set (or I misunderstood how it was
        // supposed to work).
        // Dunno if it's specific to my setup.
        width = document.documentElement.clientHeight + 20;
      }
      document.querySelector('meta[name=viewport]')
        .setAttribute('content',
          'width=' + width + ',' +
          'height=' + height + ',' +
          'initial-scale=1.0,maximum-scale=1.0,user-scalable=no');
    })
    .trigger('orientationchange');
}

다른 버전에 사용하는 뷰포트는 다음과 같습니다.

<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0" />

이제 모든 것이 잘 작동합니다.


답변

(app name)-Info.plistXCode 의 앱 파일로 이동하여 키를 추가하십시오.

view controller-based status bar appearance: NO
status bar is initially hidden : YES

이것은 문제없이 나를 위해 작동합니다.


답변

Cordova 3.1+의 경우 iOS 7+의 상태 표시 줄 동작 변경을 처리하는 플러그인이 있습니다.

상태 표시 줄을 iOS7 이전 상태로 되돌릴 수있는 방법을 포함하여 여기에 잘 설명되어 있습니다 .

플러그인을 설치하려면 다음을 실행하십시오.

cordova plugin add org.apache.cordova.statusbar

그런 다음 config.xml에 추가하십시오.

<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarStyle" value="default" />