2016-12-12 4 views
0

У меня есть TableView, и в этом UITableViewCell у меня есть UICollectionView. Теперь в моей коллекцииView. Для каждой коллекцииViewCell есть ячейка create и удаляет ключ ячейки. Поэтому для создания ячейки я должен перейти на CreateViewController, а для кнопки delete я должен удалить соответствующий 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 если (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