2016-12-12 56 views
0

我有一個TableView,並在該UITableViewCell我有一個UICollectionView。 現在在我的collectionView對於每個collectionViewCell都有一個創建單元格並刪除單元格按鈕選項。所以對於創建單元格,我必須去CreateViewController和刪除按鈕,我必須刪除各自的collectionViewCell。如何去下一個查看使用集合查看單元格?

import UIKit 

class TableCollectionCell: UITableViewCell { 

@IBOutlet weak var collectionView: UICollectionView! 

override func awakeFromNib() { 
    super.awakeFromNib() 

    //collectionView cell 
    collectionView!.register(UINib(nibName: "CreateGroupCell", bundle: nil), forCellWithReuseIdentifier: "CreateGroupCell") 
} 

override func setSelected(_ selected: Bool, animated: Bool) { 
    super.setSelected(selected, animated: animated) 

} 
} 

//Collection View 
extension TableCollectionCell : UICollectionViewDataSource ,UICollectionViewDelegateFlowLayout 
{ 
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int 
{ 
    return 4 
} 

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 
{ 
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CreateGroupCell", for: indexPath) as! CreateGroupCell 

    cell.groupName.text = "" 
    CreateCardView(viewCorner: cell.cardView) 

    if(0 == indexPath.row) 
    { 
     //cell.btnDotted.tag = indexPath.row 
     //cell.btnShare.tag = indexPath.row 
     cell.btnDotted.setImage(UIImage(named: "Info"), for: UIControlState.normal) 
     cell.btnShare.setImage(UIImage(named : "AddGroup"), for: UIControlState.normal) 
    } 

    else if(indexPath.row >= 1 && indexPath.row <= 3) 
    { 
     cell.btnDotted.isHidden = true 
     cell.btnShare.isHidden = true 
     cell.groupImage.image = UIImage(named: "group_dull_card.png") 
    } 

    else 
    { 

    } 

    return cell 
} 


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

    if (0 == indexPath.row) { 


    } 
} 

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 

    return CGSize(width: 200, height: 150) 
} 
} 

現在在我的didSelectRow方法if(indexPath.row == 0)然後我必須去CreateViewController。

我該怎麼做?我也是代表新人。

回答

0

didSelectRow方法

 if ( indexPath.row == 0) 
     { 
    self.storyboard?.instantiateViewControllerWithIdentifier("CreateViewControllerid") as! CreateViewController. 
    self.navigationController?.pushViewController(secondViewController, animated: true) 

     } 
+0

請閱讀問題。 ,看到這是我的tableViewCell類。 謝謝 – kishor0011

相關問題