2016-08-26 7 views
0

私はストーリーボードに2つのViewControllerを持っています。RootViewControllerDetailViewControllerです。 DetailViewControllerで私のラベルやその他のものが入ります。PageViewControllerが私のPickerViewを表示させない

RootViewControllerUIPageViewControllerにいくつかのViewControllerを追加しました。水平にスクロールすることができます。

問題は私がRootViewControllerUIPickerViewを追加して、アプリケーションを実行するときに表示されないという問題です。

私はPageViewControllerで遊ぶためにXcodeでページベースのアプリケーションを作成しました。プロジェクトを作成することで、デフォルトのコードがたくさん入ります。 これは私の問題で何らかの兆候があることを願っています。

override func viewDidLoad() { 
    self.pickerView = UIPickerView() 
    self.pickerView?.delegate = self 
    self.pickerView?.hidden = false 

    // Configure the page view controller and add it as a child view controller. 
    self.pageViewController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil) 
    self.pageViewController!.delegate = self 

    let startingViewController: DataViewController = self.modelController.viewControllerAtIndex(0, storyboard: self.storyboard!)! 

    let viewControllers = [startingViewController] 
    self.pageViewController!.setViewControllers(viewControllers, direction: .Forward, animated: false, completion: {done in }) 

    self.pageViewController!.dataSource = self.modelController 

    self.addChildViewController(self.pageViewController!) 
    self.view.addSubview(self.pageViewController!.view) 

    // Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages. 
    var pageViewRect = self.view.bounds.offsetBy(dx: CGFloat(0), dy: CGFloat(45)) 
    if UIDevice.currentDevice().userInterfaceIdiom == .Pad { 

     pageViewRect = CGRectInset(pageViewRect, 40.0, 40.0) 
    } 
    self.pageViewController!.view.frame = pageViewRect 

    self.pageViewController!.didMoveToParentViewController(self) 
} 

答えて

0

このbringSubviewToFront.Itはあなたに役立つことを試してみてください

[parentView bringSubviewToFront:childView];スウィフト

parentView.bringSubviewToFront(childView)で

よう

: parentView.bringSubviewToFront(self.pickerView)

+0

問題のコードを追加しました。それを確認してください – bCM

+0

それを試してみましたが、動作しません。私はボタンアクションを画面に追加し、タップしたときにPickerViewが表示され、行が選択されたときにPickerViewが消えるはずです。 – bCM

+0

このコードをテーブルビューに追加didSelectメソッド – Sanjukta

0

お使いのコントローラのビューにUIPickerViewを追加し、UIPickerView枠を設定します。

let pickerView = UIPickerView(frame: yourFrame) 
pickerView.dataSource = self 
pickerView.delegate = self 

controller.view.addSubview(pickerView) 
関連する問題