Giter Site home page Giter Site logo

ios-viewcontroller-transition-demo's Issues

发现一个内存相关的问题

class OverlayAnimationController: NSobject, UIViewControllerAnimatedTransitioning{
...
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
...
//不像容器 VC 转场里需要额外的变量来标记操作类型,UIViewController 自身就有方法跟踪 Modal 状态。
//处理 Presentation 转场:
if toVC.isBeingPresented(){
//1
containerView.addSubview(toView)
//在 presentedView 后面添加暗背景视图 dimmingView,注意两者在 containerView 中的位置。
let dimmingView = UIView()
containerView.insertSubview(dimmingView, belowSubview: toView)

        //设置 presentedView 和 暗背景视图 dimmingView 的初始位置和尺寸。
        let toViewWidth = containerView.frame.width * 2 / 3
        let toViewHeight = containerView.frame.height * 2 / 3
        toView.center = containerView.center
        toView.bounds = CGRect(x: 0, y: 0, width: 1, height: toViewHeight)

        dimmingView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
        dimmingView.center = containerView.center
        dimmingView.bounds = CGRect(x: 0, y: 0, width: toViewWidth, height: toViewHeight)

        //实现出现时的尺寸变化的动画:
        UIView.animateWithDuration(duration, delay: 0, options: .CurveEaseInOut, animations: {
            toView.bounds = CGRect(x: 0, y: 0, width: toViewWidth, height: toViewHeight)
            dimmingView.bounds = containerView.bounds
            }, completion: {_ in
                //2
                let isCancelled = transitionContext.transitionWasCancelled()
                transitionContext.completeTransition(!isCancelled)
        })
    }
    //处理 Dismissal 转场,按照上一小节的结论,.Custom 模式下不要将 toView 添加到 containerView,省去了上面标记1处的操作;
    if fromVC.isBeingDismissed(){
        let fromViewHeight = fromView.frame.height
        UIView.animateWithDuration(duration, animations: {
            fromView.bounds = CGRect(x: 0, y: 0, width: 1, height: fromViewHeight)
            }, completion: { _ in
                //2
                let isCancelled = transitionContext.transitionWasCancelled()
                transitionContext.completeTransition(!isCancelled)
        })
    }
}

}

不知楼主有没有测试过,在Modal转场实践中,这段代码会有一个小小的内存问题。多次present、dimiss切换,内存会一直以0.1M的增量上涨,不会回落,用Xcode的Leaks工具检测,并没有发现内存泄漏,我尝试着打印了containerView的subViews,发现并没有什么异常。我尝试着在这个OverlayAnimationController类中添加了一个 weak var maskView来替代原有的dimmingView,并且在dismiss中将fromView从containerView中移除,发现内存并没有回落。有些困惑,特来请教,谢谢了!

嵌套在TabBar的自定义NavigationController转场问题

今天在项目中使用自定义Navigation的转场时发现这样一个问题:
如果自定义了NavigationController 转场动画,并且在该NavigationController 外面套了一个TabBarController,在AVC 推到 BVC 过程中,设置 BVC 的 hidesBottomBarWhenPushed = YES 的情况下,tabBar 有一个很明显的滑入画出的动作。如下图,这种情况下应该如何处理?

tabbartrans

ScrollTabBarController demo 中的bug

出现bug为点击任何按钮都无反应
复现方式:
1、func handlePan(panGesture: UIPanGestureRecognizer) 内部打一个断点,然后松开断点
2、滑动时,快速点击 tabbaritem,多次这样会出现黑色界面,点击无反应

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.