title: PageViewController in NavigationController child ViewController of scrolling issue in ios
body: <ol>
  <li>Navigation Controller - Parent</li>
  <li>Page ViewController - Child of Navigation Controller</li>
  <li>DetailsViewController - ViewController to be displayed in PageViewController.</li>
  </ol>
  
  <p>My DetailsViewController contains scrollview and array of detailsviewController with different data is passed to pageviewcontroller.</p>
  
  <p>The problem is only first viewController of pageviewcontroller is shown under navigartionbar and its scrollview is working.</p>
  
  <p>But rest are pushed under navigation controller and scrollview is not working.</p>
  
  <p><a href="https://i.stack.imgur.com/etjEp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/etjEp.png" alt="First Details view controller working properly"></a></p>
  
  <p><a href="https://i.stack.imgur.com/HB5Gp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HB5Gp.png" alt="Next DetailsViewController from dataset when i swipe. Here the content is pushed under navigation bar and scrollview not working"></a></p>
  
  <p>1st image : First Details view controller working properly</p>
  
  <p>2nd Image : Next DetailsViewController from dataset when i swipe. Here the content is pushed under navigation bar and scrollview not working</p>
  
  <p>After doing further research i found that navigationcontroller property of  rest of  detailsviewcontroller except first is nil.</p>
  
  <pre><code> //
  //  PagerViewController.swift
  //  
  //
  //  Created by Admin on 13/07/16.
  // 
  //
  
  import UIKit
  
  class PagerViewController: UIPageViewController {
  
      var result =  Array&lt;SearchResult&gt;();
      var mainStoryBoard  = UIStoryboard(name: "Main", bundle: nil);
      var resultSet = [UIViewController]();
      var currentIndex = 0;
      // MARK: - Life cycle Methods
      override func viewDidLoad() {
          super.viewDidLoad();
          dataSource = self;
          delegate = self;
          generateDatset();
          let initialViewController  = resultSet[currentIndex] ;
          let viewControllers = NSArray(objects : initialViewController);
          setViewControllers(viewControllers as? [UIViewController], direction: .Forward, animated: true, completion: nil);
          self.navigationController!.edgesForExtendedLayout = .None;
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      // MARK: - Dataset Initialisation
  
      func generateDatset()  {
  
          for searchResult in result {
              let viewController  = mainStoryBoard.instantiateViewControllerWithIdentifier(Constants.STORYBOARDUIFIELDS.DETAILSVIEWCONTROLLER) as? DetailsViewController;
  
              viewController?.searchResult =  searchResult;
              resultSet.append(viewController!)
          }
  
      }
  
  
  
  
  
  
  }
  
  // MARK: - UIPageViewControllerDataSource
  
  extension PagerViewController : UIPageViewControllerDataSource {
  
      func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -&gt; UIViewController? {
  
  
          guard let viewControllerIndex  = resultSet.indexOf(viewController)  else {
              return nil;
          }
  
          let nextIndex  = viewControllerIndex + 1;
  
          guard  resultSet.count &gt; nextIndex else {
                         return nil;
          }
  
          currentIndex = nextIndex;
          return resultSet[nextIndex];
  
  
      }
  
      func scrollToNext(viewControllers : UIViewController) {
          setViewControllers([viewControllers], direction: .Forward, animated: true, completion: nil)
      }
  
      func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -&gt; UIViewController? {
         guard let viewControllerIndex = resultSet.indexOf(viewController) else {
              return nil;
          }
          let previousIndex =  viewControllerIndex - 1;
  
          guard previousIndex &gt;= 0  else {
              return nil;
          }
          currentIndex  = previousIndex;
          return resultSet[previousIndex];
  
      }
  
  }
  
  
   //
  //  DetailsViewController.swift
  //
  //
  //  Created by Admin on 13/07/16.
  //  
  //
  
  import UIKit
  
  class DetailsViewController: UIViewController {
  
  
      var searchResult  : SearchResult? = nil;
  
      @IBOutlet weak var ShoeImageView: UIImageView!
  
      @IBOutlet weak var DnsItemCodeLabel: UILabel!
  
      @IBOutlet weak var GeneralDetailsCollView: UICollectionView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          //print(navigationController)
  
          DnsItemCodeLabel.text = "\(searchResult!.DNS!) - \(searchResult!.ItemCode!)";
  
          // converting base64encoded image into nsdata and then to ui image
  
          let image = UIImage(data: NSData(base64EncodedString: searchResult!.Image!, options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)!)
  
          ShoeImageView.image = image;
  
          // Assigning source to CollectionView
  
          GeneralDetailsCollView.dataSource = self;
          print(navigationController)
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
  
  
  
  }
  
  // MARK: - UICollectionViewDataSource
  
  extension DetailsViewController : UICollectionViewDataSource  {
  
  
      // returns the number of items
  
      func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return (searchResult!.summaryItems?.count)!;
      }
  
      //return the cell for given position
  
      func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
            let cell = collectionView.dequeueReusableCellWithReuseIdentifier(Constants.STORYBOARDUIFIELDS.GENRAL_DETAILS_CELL, forIndexPath: indexPath) as! GeneralDetailsCell
          if let data = searchResult?.summaryItems![indexPath.row] {
              cell.TitleLable.text =  data.Title!;
              cell.ValueLabel.text  = data.Value!;
          }
  
          return cell
  
      }
  
  
  }
  </code></pre>