2016-08-31 14 views
0

ステータスバーがボタンを押して消えてしまい、すべての作品が隠れていて木に隠れていますが、最後のビューコントローラに戻ると白いステータスバーが隠れますが、黒のステータスバーが表示されます。表示されているとおり、ボタンが押されたときに使用されているのと同じコードを使用しています。ここ ステータスバーが非表示になってもまだ黒で表示されています

は、使用されるコードです:

//下にありません黒のステータスバーに白いステータスバーを非表示にする作品でボタンを押します。

@IBAction func onPlayPressed(sender: AnyObject) { 
    start() 


    isHidden = !isHidden 
    UIView.animateWithDuration(0.3) {() -> Void in 
     self.setNeedsStatusBarAppearanceUpdate() 

} 
    self.navigationController?.hidesBarsOnTap = false 
    self.navigationController?.setNavigationBarHidden(true, animated: true) 

//このセクションでは、白のステータスバーは非表示になりますが、黒色のステータスバーはその下に残ります。

override func viewWillDisappear(animated: Bool) { 
    synth.pause() 
    vox.pause() 

    isHidden = true 
    UIView.animateWithDuration(0.3) {() -> Void in 
     self.setNeedsStatusBarAppearanceUpdate() 

    } 
    self.navigationController?.hidesBarsOnTap = false 
    self.navigationController?.setNavigationBarHidden(true, animated: true) 

ご協力いただければ幸いです。

すべてのベスト トニーメリット

答えて

0

いくつかの用語

ステータスバー:

enter image description here

ナビゲーションバー:

enter image description here

ナビゲーションおよびステータス・バー:

enter image description here

は私のサンプルをお試しください:

ViewController.swift

import UIKit 

class ViewController: UIViewController { 

@IBOutlet var hideButton: UIButton! 

override func viewDidLoad() { 
    super.viewDidLoad() 
    // Do any additional setup after loading the view, typically from a nib. 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
    if (self.navigationController?.navigationBarHidden)! { 
     hideButton.setTitle("show", forState: .Normal) 
    } 
} 

@IBAction func hideNavigationBar(sender: AnyObject) { 
    self.navigationController?.hidesBarsOnTap = false 
    self.navigationController?.setNavigationBarHidden(!(self.navigationController?.navigationBarHidden)!, animated: true) 
} 

@IBAction func goBack(sender: AnyObject) { 
    self.navigationController?.popViewControllerAnimated(true) 
} 
} 

Main.storyboard

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="T9D-e2-4rQ"> 
<dependencies> 
    <deployment identifier="iOS"/> 
    <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> 
</dependencies> 
<scenes> 
    <!--View Controller--> 
    <scene sceneID="ZDJ-xV-lml"> 
     <objects> 
      <viewController id="3W3-SS-KDU" sceneMemberID="viewController"> 
       <layoutGuides> 
        <viewControllerLayoutGuide type="top" id="Mxj-5M-2iY"/> 
        <viewControllerLayoutGuide type="bottom" id="3C4-b8-R1X"/> 
       </layoutGuides> 
       <view key="view" contentMode="scaleToFill" id="Hr5-jU-7uD"> 
        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> 
        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 
        <subviews> 
         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DLX-GN-6Nd"> 
          <rect key="frame" x="283" y="285" width="34" height="30"/> 
          <state key="normal" title="push"/> 
          <connections> 
           <segue destination="aX5-Sj-vzs" kind="show" id="5hq-PZ-fji"/> 
          </connections> 
         </button> 
        </subviews> 
        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 
        <constraints> 
         <constraint firstItem="DLX-GN-6Nd" firstAttribute="centerY" secondItem="Hr5-jU-7uD" secondAttribute="centerY" id="hM7-eb-ZcS"/> 
         <constraint firstItem="DLX-GN-6Nd" firstAttribute="centerX" secondItem="Hr5-jU-7uD" secondAttribute="centerX" id="yTt-om-iNF"/> 
        </constraints> 
       </view> 
       <navigationItem key="navigationItem" id="PzV-EJ-7im"/> 
      </viewController> 
      <placeholder placeholderIdentifier="IBFirstResponder" id="GKQ-Ot-Zmx" userLabel="First Responder" sceneMemberID="firstResponder"/> 
     </objects> 
     <point key="canvasLocation" x="865" y="375"/> 
    </scene> 
    <!--View Controller--> 
    <scene sceneID="dHO-Tf-TVb"> 
     <objects> 
      <viewController id="aX5-Sj-vzs" customClass="ViewController" customModule="stackoverflow_39240675" customModuleProvider="target" sceneMemberID="viewController"> 
       <layoutGuides> 
        <viewControllerLayoutGuide type="top" id="a3I-YL-ZHX"/> 
        <viewControllerLayoutGuide type="bottom" id="EDl-yb-Y7O"/> 
       </layoutGuides> 
       <view key="view" contentMode="scaleToFill" id="dve-Qr-cm1"> 
        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> 
        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 
        <subviews> 
         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XYd-b4-iN3"> 
          <rect key="frame" x="285" y="285" width="30" height="30"/> 
          <state key="normal" title="hide"> 
           <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 
          </state> 
          <connections> 
           <action selector="hideNavigationBar:" destination="aX5-Sj-vzs" eventType="touchUpInside" id="8OZ-fj-hkz"/> 
          </connections> 
         </button> 
         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KHT-Tm-0Sw"> 
          <rect key="frame" x="283" y="323" width="34" height="30"/> 
          <state key="normal" title="back"> 
           <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 
          </state> 
          <connections> 
           <action selector="goBack:" destination="aX5-Sj-vzs" eventType="touchUpInside" id="0Gj-6r-RH0"/> 
          </connections> 
         </button> 
        </subviews> 
        <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> 
        <constraints> 
         <constraint firstItem="XYd-b4-iN3" firstAttribute="centerY" secondItem="dve-Qr-cm1" secondAttribute="centerY" id="4oU-lu-cib"/> 
         <constraint firstItem="KHT-Tm-0Sw" firstAttribute="centerX" secondItem="XYd-b4-iN3" secondAttribute="centerX" id="DHD-BE-uLP"/> 
         <constraint firstItem="KHT-Tm-0Sw" firstAttribute="top" secondItem="XYd-b4-iN3" secondAttribute="bottom" constant="8" symbolic="YES" id="Mfb-X2-i3d"/> 
         <constraint firstItem="XYd-b4-iN3" firstAttribute="centerX" secondItem="dve-Qr-cm1" secondAttribute="centerX" id="UY9-eH-ABh"/> 
        </constraints> 
       </view> 
       <connections> 
        <outlet property="hideButton" destination="XYd-b4-iN3" id="uLV-9H-ZwF"/> 
       </connections> 
      </viewController> 
      <placeholder placeholderIdentifier="IBFirstResponder" id="taE-x0-pMJ" userLabel="First Responder" sceneMemberID="firstResponder"/> 
     </objects> 
     <point key="canvasLocation" x="1525" y="376"/> 
    </scene> 
    <!--Navigation Controller--> 
    <scene sceneID="g8h-An-4td"> 
     <objects> 
      <navigationController automaticallyAdjustsScrollViewInsets="NO" id="T9D-e2-4rQ" sceneMemberID="viewController"> 
       <toolbarItems/> 
       <navigationBar key="navigationBar" contentMode="scaleToFill" id="8Zu-zN-61c"> 
        <rect key="frame" x="0.0" y="0.0" width="320" height="44"/> 
        <autoresizingMask key="autoresizingMask"/> 
       </navigationBar> 
       <nil name="viewControllers"/> 
       <connections> 
        <segue destination="3W3-SS-KDU" kind="relationship" relationship="rootViewController" id="P8d-UH-2I1"/> 
       </connections> 
      </navigationController> 
      <placeholder placeholderIdentifier="IBFirstResponder" id="8cC-0q-iMj" userLabel="First Responder" sceneMemberID="firstResponder"/> 
     </objects> 
     <point key="canvasLocation" x="53" y="375"/> 
    </scene> 
</scenes> 
</document> 
+0

こんにちはワシーリーは、お返事ありがとうございました。申し訳ありませんが、ステータスバーにバッテリーと通信事業者のロゴが表示されているときは明確ではありませんでした。私はバーを残すとき、彼らはそこにとどまっていますが、白ではなく黒で、私のプレーボタンを押すと、彼らは消えて、彼らの痕跡はありません。私はこれを回避するためにステータスバーのロゴ付きコントローラーの間に全体のナビゲーションバーとステータスバーを置いておきました。お時間をいただき、ありがとうございました。すべてのbset –

+0

すべてが順調です。私はあなたを助けてうれしいです。では、viewDidAppear関数のナビゲーションバーを非表示にしたいのですか? –

+0

あなたの質問に対する解決策を見つけましたか? –

関連する問題