2016-03-06 8 views
0

Данные 3 контроллера: A, B, C A имеет скрытую навигационную панель. Вызывает контроллер B через StoryboardReference. Контроллер B показывает панель навигации в режиме просмотраDidLoad. У него есть панель поиска и коллекцияView. Смотрите скриншот A моей раскадровки. Вызывает контроллер C, если нажата ячейка.Панель поиска за навигационной панелью

Проблема: Если A называет B, панель поиска находится за навигационной панелью (снимок экрана B). Он появляется при переходе от C в B (снимок экрана C).

Навигационная панель уже полупрозрачна. Есть идеи?

EDIT

я понял, что мой анимированный Переход вызывает мою проблему.

Возможно, вы обнаружили ошибку?

class ZoomInCircleViewTransition: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate { 

    var transitionContext: UIViewControllerContextTransitioning? 

    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { 
     return 0.6 
    } 

    func animateTransition(transitionContext: UIViewControllerContextTransitioning) { 
     self.transitionContext = transitionContext 

     guard let toViewController: UIViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) else { 
      return 
     } 

     guard let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) else {   return 
     } 

     guard let fromViewTransitionFromView = fromViewController as? TransitionFromViewProtocol else { 
      return 
     } 

     let imageViewSnapshot = fromViewTransitionFromView.getViewForTransition() 

     let endFrame = CGRectMake(-CGRectGetWidth(toViewController.view.frame)/2, -CGRectGetHeight(toViewController.view.frame)/2, CGRectGetWidth(toViewController.view.frame)*2, CGRectGetHeight(toViewController.view.frame)*2) 

     if let containerView = transitionContext.containerView(){ 
      containerView.addSubview(fromViewController.view) 
      containerView.addSubview(toViewController.view) 
      containerView.addSubview(imageViewSnapshot) 
     } 


     let maskPath = UIBezierPath(ovalInRect: imageViewSnapshot.frame) 
     let maskLayer = CAShapeLayer() 
     maskLayer.frame = toViewController.view.frame 
     maskLayer.path = maskPath.CGPath 
     toViewController.view.layer.mask = maskLayer 

     let quadraticEndFrame = CGRect(x: endFrame.origin.x - (endFrame.height - endFrame.width)/2, y: endFrame.origin.y, width: endFrame.height, height: endFrame.height) 
     let bigCirclePath = UIBezierPath(ovalInRect: quadraticEndFrame) 

     let pathAnimation = CABasicAnimation(keyPath: "path") 
     pathAnimation.delegate = self 
     pathAnimation.fromValue = maskPath.CGPath 
     pathAnimation.toValue = bigCirclePath 
     pathAnimation.duration = transitionDuration(transitionContext) 
     maskLayer.path = bigCirclePath.CGPath 
     maskLayer.addAnimation(pathAnimation, forKey: "pathAnimation") 


     let hideImageViewAnimation = { 
      imageViewSnapshot.alpha = 0.0 
     } 

     UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: hideImageViewAnimation) { (completed) -> Void in 
     } 

     let scaleImageViewAnimation = { 
      imageViewSnapshot.frame = quadraticEndFrame 
     } 
     UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: scaleImageViewAnimation) { (completed) -> Void in 
      // After the complete animations have endet 
      imageViewSnapshot.removeFromSuperview() 
      toViewController.view.layer.mask = nil 
     } 
    } 

    override func animationDidStop(anim: CAAnimation, finished flag: Bool) { 
     if let transitionContext = self.transitionContext { 
      transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) 
     } 
    } 

    // MARK: UIViewControllerTransitioningDelegate protocol methods 

    // return the animataor when presenting a viewcontroller 
    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
     return self 
    } 

    // return the animator used when dismissing from a viewcontroller 
    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
     return self 
    } 
} 
+0

Попробуйте установить 'self.edgesForExtendedLayout = .None' в viewDidLoad – muazhud

+0

уже установлен ... – netshark1000

ответ

1

Я считаю, что сталкивался с некоторыми аналогичными проблемами в своем приложении, но столкнулся с трудностями из-за всех вещей, которые у вас нет. Мое решение состояло в том, чтобы поместить значок поиска в панель навигации, а затем, чтобы контроллер поиска скользил вниз по навигационной панели, оставив ее вне таблицы/прокрутки. Вот моя реализация (должна быть завершена)

import UIKit 

class tvc: UITableViewController, UISearchBarDelegate, UISearchControllerDelegate { 

var searchController:UISearchController! 

@IBAction func startSearch() { 
    self.navigationController?.presentViewController(self.searchController, animated: true, completion: {}) 
} 

override func viewDidDisappear(animated: Bool) { 
    cancelSearch(self) 
} 

override func viewDidLoad() { 
    super.viewDidLoad() 

    searchController = UISearchController(searchResultsController: nil) 
    searchController.searchResultsUpdater = self 
    searchController.dimsBackgroundDuringPresentation = false 
    searchController.delegate = self 
    searchController.hidesNavigationBarDuringPresentation = false 
    searchController.loadViewIfNeeded() /* Fixes bug in iOS http://stackoverflow.com/questions/32675001/uisearchcontroller-warning-attempting-to-load-the-view-of-a-view-controller */ 
    definesPresentationContext = true 
    tableView.sectionIndexBackgroundColor = UIColor.clearColor() 
    tableView.sectionIndexTrackingBackgroundColor = UIColor.clearColor() 
} 

extension tvc: UISearchResultsUpdating { 
// MARK: - UISearchResultsUpdating Delegate 
func updateSearchResultsForSearchController(searchController: UISearchController) { 
    filterContentForSearchText(searchController.searchBar.text!) 
    } 
} 

func cancelSearch(sender: AnyObject?) { 
if sender!.searchController.active == true { 
sender?.searchController.resignFirstResponder() 
sender!.navigationController!!.dismissViewControllerAnimated(false, completion: {}) 
sender!.searchController.searchBar.text = "" 
sender!.searchController.active = false 
    } 
} 
+0

извините - но это не помогает – netshark1000

0

Я думаю, что проблема заключается в ваш являются либо вы не устанавливая рамки для imageViewSnapshot или установить неправильную рамку. Поскольку imageViewSnapshot включает в себя панель поиска, вам необходимо установить такой кадр, если он идет за панель навигации. или imageViewSnapshot должен содержать только видимую область ofViewTransitionFromView.

+0

Панель поиска является частью toViewController. imageViewSnapshot элемент fromViewController, где начинается анимация. Я не понимаю, почему просмотр коллекции виден, а поисковая панель - нет. – netshark1000

Смежные вопросы