2016-03-21 8 views
1

SplitViewControllerは、連絡先リストとその連絡先の詳細を持つ2つのビューを表示しています。 SplitViewはiPadでうまく動作しますが、iPhoneにはいくつか問題があります。UIControlはiPhoneで私のすべてのビューをブロックします

ユーザが.touchDown interactionが存在するかどうかをチェックするUIControlがあり、コンタクトモードの編集中かどうかによってこのUIControlを有効または無効にするメソッドが呼び出されます画面かどうかと相互作用する:ユーザーが連絡先リストとの相互作用を遮断することによって、変更場合は新しいものを作成する/別の連絡先を編集している間

private var disableInteractionClosure: (()->())? 
    private lazy var interactionOverlay: UIControl = { 
     let c = UIControl() 
     c.autoresizingMask = [.FlexibleHeight, .FlexibleWidth] 
     c.addTarget(self, action: "interactionOverlayAction", forControlEvents: .TouchDown) 
     return c 
    }() 

    func disableInteractionWhileEditingWithClosure(callback:()->()) { 
     if disableInteractionClosure == nil { 
      disableInteractionClosure = callback 
      /* display control overlay */ 
      interactionOverlay.frame = navigationController!.view.bounds 
      navigationController!.view.addSubview(interactionOverlay) 
     } 
    } 

    func interactionOverlayAction() { 
     disableInteractionClosure!() 
    } 

    func enableInteraction() { 
     disableInteractionClosure = nil 
     interactionOverlay.removeFromSuperview() 
    } 

基本的UIControlコンタクトの切り替えからユーザーをブロックするために使用されています編集/作成ビューで作成されました。ポップアップを表示するメソッドを起動しますpは言った "あなたは保存せずに続行したいですか? 「キャンセルまたは継続:

func cancel() { 
     self.view.endEditing(true) 

     let closure:()->() = { 
      self.layoutView.willResign() 
      self.delegate?.tabDetailsControllerDidCancel(self) 
     } 

      if layoutView.hasChanges() { 
       MKAlertViewController().instantaneousAlert(title: "Modification apportées", message: "Êtes-vous sur de vouloir continuer sans sauvegarder les modifications ?", confirmButtonTitle: "Oui", cancelButtonTitle: "Annuler", confirmed: {() -> Void in 
        closure() 
        }, canceled: {() -> Void in 

       }) 
      } else { 
       closure() 
      } 

    } 

それを手動で解除する場合にのみ、UIControlだけマスタービューの上にあるとするとき詳細ビュー(iPad 3D Debugging view)の編集モードで有効になっているので、iPad上で正常に動作しますので、ポップアップショー編集/作成中に連絡先を変更しようとしているときに、splitViewがiPadsとiPhoneで同じように機能しないため、マスタービューが詳細ビューの上に表示されているようで、UIControlも上記(iPhone 3D Debugging view)、すべての画面で対話をブロックし、キャンセルポップアップをクリックするとどこにでも表示されます。

MasterViewが表示されていてもどこにも表示されていない場合にのみ、このUIControlを有効/表示する方法を教えてもらえますか?ありがとう。

答えて

0

私は、詳細ビューにviewWillDisappearを使用して終了:

override func viewWillDisappear(animated: Bool) { 

     super.viewWillDisappear(animated) 

     if self.isMovingFromParentViewController() || self.isBeingDismissed() { 
      if editingMode { 
       shared.contactsListController.disableInteractionWhileEditingWithClosure({ (_) in 
        self.tabDetailsController.cancel() 
       }) 
       shared.contactsListController.disableToolbar() 
      } else { 
       shared.contactsListController.enableInteraction() 
       shared.contactsListController.enableToolbar() 
      } 
      self.navigationController?.toolbar.alpha = 1 
     } 
    } 

とマスタービュー上disableInteractionWhileEditingWithClosure方法変更:

func disableInteractionWhileEditingWithClosure(callback:()->()) { 
     if disableInteractionClosure == nil { 
      disableInteractionClosure = callback 
      /* display control overlay */ 
      interactionOverlay.frame = navigationController!.view.bounds 

      view.addSubview(interactionOverlay) // this line 
     } 
    } 

をし、それが動作します! :)

関連する問題