- Навигационный контроллер - Родитель
- Page ViewController - Дитя Navigation Controller
- DetailsViewController - ViewController будет отображаться в PageViewController.
My DetailsViewController содержит scrollview и массив detailsviewController с различными данными передается на просмотр страницы.PageViewController в NavigationController ребенка ViewController скроллинга выпуска в ИОС
Проблема заключается только в первом просмотре. Контроллер просмотра страницы отображается под навигационной панелью, и его scrollview работает.
Но отдых находится под навигационным контроллером, а функция прокрутки не работает.
первое изображение: Сначала детали вид контроллер работает правильно
2-ое изображение: Следующая DetailsViewController из набора данных, когда я красть. Здесь содержимое подталкивается под панель навигации, а scrollview не работает
После проведения дальнейших исследований я обнаружил, что свойство навигационного контроллера остальной части контроллера просмотра, кроме первого, равно нулю.
//
// PagerViewController.swift
//
//
// Created by Admin on 13/07/16.
//
//
import UIKit
class PagerViewController: UIPageViewController {
var result = Array<SearchResult>();
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) -> UIViewController? {
guard let viewControllerIndex = resultSet.indexOf(viewController) else {
return nil;
}
let nextIndex = viewControllerIndex + 1;
guard resultSet.count > 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) -> UIViewController? {
guard let viewControllerIndex = resultSet.indexOf(viewController) else {
return nil;
}
let previousIndex = viewControllerIndex - 1;
guard previousIndex >= 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) -> Int {
return (searchResult!.summaryItems?.count)!;
}
//return the cell for given position
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> 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
}
}
Вы имели в виду, что ваши DetailsViewControllers не показаны, кроме первого? –
Пока не отображается подробный вид, но кроме первого, все остальные подталкиваются под панель навигации. Следовательно, верхняя часть перекрывается с navgaiton bar nad alos scrollview внутри не работает из-за этой проблемы –
@ChiragJain: можете ли вы добавить скриншоты? –