2017-06-05 7 views
0

私はPopupDialogライブラリを使用し、負荷にポップアップをタップすると、以下のコードに示すように、というボタンがありますよ。そこに私のポップアップ内ポップアップが開いているときにビューコントローラを開く方法 - 迅速な3

// Create the dialog 
let popup_around_me = AroundMePopUpViewController(nibName: "popup_around_me", bundle: nil) 
popup_around_me.gh = self.getJobByLatitude(latitude: marker.position.latitude) 
let popup = PopupDialog(viewController: popup_around_me, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true) 

present(popup, animated: true, completion: nil) 
//print("marker.position.latitude: \(marker.position.latitude)") 

コントローラを開く2つのボタンです。

ナビゲーションバーを使用しているため、まずポップアップを閉じてからコントローラを開く必要があります。そうしないと、ナビゲーションバーがロードされません。

しかし、これが正しい方法かどうかはわかりません。 問題が解決しない場合、どうすればいいですか(ポップアップを閉じてコントローラを開く)

私のボタン機能:

func cliclOnContent(tapGestureRecognizer: UITapGestureRecognizer) 
    { 
     print("job id: \(self.gh.id)") 

//below codes not load my navigation. 
//  let vc = self.storyboard!.instantiateViewController(withIdentifier: "ContentAJobViewController") as! ContentAJobViewController 
//  vc.job_id = self.gh.id 
//  self.navigationController?.pushViewController(vc, animated: true) 

     // let storyboard = UIStoryboard(name: "Main", bundle: nil) 
//  let controller = storyboard?.instantiateViewController(withIdentifier: "ContentAJobViewController") as! ContentAJobViewController 
//  controller.job_id = self.gh.id 
//  self.present(controller, animated: true, completion: nil) 

    } 
+0

使用している「PopupDialog」への参照(リンク)を提供できますか? –

+0

https://github.com/Orderella/PopupDialog –

+0

ポップアップを閉じるには 'popup.tapButtonWithIndex'を使用できますか? –

答えて

0

編集:

実際にあなたがそれを閉じる必要はありません。それは自動的に自動的に閉じます。それぞれのボタン操作でViewコントローラを呼び出すだけです。

私はView Controllerを持っており、キャンセルボタンのようにsegueを使って電話をしました。

enter image description here

そして、私の出力私はちょうど迅速な対応のために彼らのデモファイルを使用方法this.byのようなものです。

enter image description here

+0

ポップアップを閉じるには?ポップアップを検出する方法は閉じられていますか?それを検出する機能はありますか? –

0

私はPopupDialogを述べた上記のライフサイクルに慣れていないんだけど、それはUIAlertControllerのように動作している場合、ボタンのアクションのいずれかが完了したときに自動的に閉じます。

カスタムPopupDialogバージョンを使用しているようです。あなたはこれに似た、あなたのボタンとボタンのアクションを実装する必要があります。

あなたが segueの代わりに navigation barを使用しているので、あなたが他のVCをオープンする場所、この「オープンVC」ボタンアクション内 self.gotoMyOtherViewController()への呼び出しがある
func showCustomDialog(animated: Bool = true) { 

     // Create a custom view controller 
     let popup_around_me = AroundMePopUpViewController(nibName: "popup_around_me", bundle: nil) 


     let popup_around_me = AroundMePopUpViewController(nibName: "popup_around_me", bundle: nil) 
     popup_around_me.gh = self.getJobByLatitude(latitude: marker.position.latitude) 
     // Create the dialog 
     let popup = PopupDialog(viewController: popup_around_me, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true) 


     // Create first button 
     let buttonOne = CancelButton(title: "CANCEL", height: 60) { 
      // Do what you want when you cancel 
     } 

     // Create second button 
     let buttonTwo = DefaultButton(title: "Open VC", height: 60) { 
      self.gotoMyOtherViewController() 
     } 

     // Add buttons to dialog 
     popup.addButtons([buttonOne, buttonTwo]) 

     // Present dialog 
     present(popup, animated: true, completion: nil) 
    } 
} 

お知らせ

func gotoMyOtherViewController(){ 
    let vc = self.storyboard!.instantiateViewController(withIdentifier: "ContentAJobViewController") as! ContentAJobViewController 
    vc.job_id = self.gh.id   
    navigationController?.pushViewController(vc, animated: true) 
} 
関連する問題