8000 Fixed: containerViewにaddSubviewしたImageViewが増え続けていたものを修正 by kunihara · Pull Request #1 · yusayusa/ZoomAnimation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixed: containerViewにaddSubviewしたImageViewが増え続けていたものを修正 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ZoomAnimation/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ class DetailViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.whiteColor()
self.imageView!.image = self.image
}

func createImageView() -> UIImageView? {

guard let detailImageView = self.imageView else {
return nil
}
let imageView = UIImageView(image: self.image)
let imageView = UIImageView(image: self.imageView!.image)
imageView.contentMode = .ScaleAspectFit
imageView.frame = detailImageView.frame
return imageView
}

@IBOutlet private weak var imageView : UIImageView?
@IBOutlet var imageView : UIImageView?
}
10 changes: 5 additions & 5 deletions ZoomAnimation/TransitionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class TransitionController: NSObject, UIViewControllerAnimatedTransitioning {
containerView.addSubview(sourceImageView)

toVC.view.alpha = 0.0
(toVC as! DetailViewController).imageView!.hidden = true
(toVC as! DetailViewController).image = sourceImageView.image

UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.05, options: .CurveEaseInOut, animations: { () -> Void in

Expand All @@ -92,7 +94,8 @@ class TransitionController: NSObject, UIViewControllerAnimatedTransitioning {
toVC.view.alpha = 1.0

}) { (finished) -> Void in

(toVC as! DetailViewController).imageView?.hidden = false
sourceImageView.removeFromSuperview()
// アニメーション終了
transitionContext.completeTransition(true)
}
Expand All @@ -112,9 +115,6 @@ class TransitionController: NSObject, UIViewControllerAnimatedTransitioning {
guard let containerView = transitionContext.containerView() else {
return
}

// 最初からcontainerViewがsubviewとして持っているfromVC.viewを削除
fromVC.view.removeFromSuperview()

// toView -> fromViewの順にaddSubview
containerView.addSubview(toVC.view)
Expand All @@ -136,7 +136,7 @@ class TransitionController: NSObject, UIViewControllerAnimatedTransitioning {

}) { (finished) -> Void in

sourceImageView.hidden = true
sourceImageView.removeFromSuperview()

(toVC as? ViewController)?.selectedImageView?.hidden = false

Expand Down
0