2017-07-08 6 views
2

collectionviewを実装しましたがうまくいきますが、FlipAnimationがセルから新しいView Controllerを開いてセルに戻したいと思っています。どのようにsame.Asを達成するために私はアニメーションの任意のアイデアを持っていません。助けてください。ありがとう。 コードFlipAnimationを使ってすべてのCollectionViewCellから新しいViewControllerを開き、Swift 3を終了する方法

import UIKit 

    class DashBoardVC: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout 
    { 

    @IBOutlet weak var logoutbtn: UIButton! 
    @IBOutlet weak var menubtn: UIButton! 

    var names = ["Dashboard","Add Book","Delete Book","Search Book","On Demand","About Us"] 

    var useimages = [UIImage(named:"dashboard_icon2"),UIImage(named:"book_blue_add"),UIImage(named:"book_blue_delete"),UIImage(named:"book_blue_view"),UIImage(named:"book_blue_new"),UIImage(named:"businesspeople2"),] 

override func viewDidLoad() 
     { 
      super.viewDidLoad() 

     } 

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int 
     { 
       return names.count 
      } 
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 
     { 
     let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellcollect", for: indexPath) as! mycollectioncell 

     cell.collectLabel.text! = names[indexPath.row] 
     cell.collectimage.image = useimages[indexPath.row] 
     return cell 
    } 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize 
     { 
     let padding : CGFloat = 15 
     let collectionViewSize = collectionView.frame.size.width - padding 
     return CGSize(width: collectionViewSize/2, height: collectionViewSize/2) 

     } 

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) 
     { 


    let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 

    switch(indexPath.row) 
    { 
    case 0: 
    let desVC = storyboard.instantiateViewController(withIdentifier: "DashboardClick") as! DashboardClick 
    self.navigationController?.pushViewController(desVC, animated: true) 
     break 
    case 1: 
     let desVC = storyboard.instantiateViewController(withIdentifier: "AddBookVC") as! AddBookVC 
     self.navigationController?.pushViewController(desVC, animated: true)    
     break 
    case 2: 
     let desVC = storyboard.instantiateViewController(withIdentifier: "DeleteBookVC") as! DeleteBookVC 
     self.navigationController?.pushViewController(desVC, animated: true) 
     break 

    case 3: 
     let desVC = storyboard.instantiateViewController(withIdentifier: "SearchBookVC") as! SearchBookVC 
     self.navigationController?.pushViewController(desVC, animated: true) 
     break 

    case 4: 
     let desVC = storyboard.instantiateViewController(withIdentifier: "onDemandBookVC") as! onDemandBookVC 
     self.navigationController?.pushViewController(desVC, animated: true) 

     break 
    default: 
     break 
    } 


     } 

override func viewWillAppear(_ animated: Bool) 
{ 
    self.navigationController?.navigationBar.isHidden = true 
    self.navigationController?.toolbar.isHidden = true 
    } 

@IBAction func menutapped(_ sender: Any) 
     { 
    var appdelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate 

    appdelegate.centerContainer?.toggle(MMDrawerSide.left, animated: true, completion: nil) 


      } 
     } 

mycollectioncell.swiftここ

import UIKit 

class mycollectioncell: UICollectionViewCell { 


@IBOutlet weak var collectLabel: UILabel! 

@IBOutlet weak var collectimage: UIImageView! 



} 

答えて

1

学生はNSObjectClass

var Arraydata:[Student] = [] 
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 
     let arr = Arraydata[indexPath.row] 
     if indexPath.row == arr 
     { 
      let story = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController 

    UIView.beginAnimations("", context: nil) 
    UIView.setAnimationDuration(1.0) 
    UIView.setAnimationCurve(UIViewAnimationCurve.easeInOut) 
    UIView.setAnimationTransition(UIViewAnimationTransition.flipFromRight, for: (self.navigationController?.view)!, cache: false) 
    self.navigationController?.pushViewController(story, animated: true) 
    UIView.commitAnimations() 

     } 
    } 
+0

返事に感謝ですが、plzは私の編集した質問を参照してください。 – deltami

+0

私はコードを更新しました。だからあなたのアプリにコードを入れてみてください。それは100%働いています。 –

+0

これはちょうど私がちょっと欲しいものです。シーンの裏に黒い背景があります。 – deltami

関連する問題