2017-06-17 71 views
0

我有一个自定义的可扩展表格视图。展开的tableViewCell在其中包含一些包含一些动画的按钮。所以当tableViewCell展开时:tableViewCell中的动画按钮

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "Cells", for: indexPath) as! ProfileTableViewCell 
    if isExpanded && self.selectedIndex == indexPath { 
       cell.CustomView.frame = CGRect(x: 7, y: 8, width: 359, height: 283) 
      } 
      else { 
      cell.CustomView.frame = CGRect(x: 7, y: 8, width: 359, height: 115) 

      }} 

您可以看到更多细节的细胞。在展开的单元格底部,有一个按钮。当你点击按钮三个按钮显示:

@IBAction func UserAddClicked(_ sender: Any) { 
     if UserAdd.currentImage == #imageLiteral(resourceName: "icons8-Plus-48"){ 
      UIView.animate(withDuration: 0.3, animations: { 

       self.UserShare.alpha = 1 
       self.UserEdit.alpha = 1 
       self.UserDelete.alpha = 1 

      }) 
     }else { 
      UIView.animate(withDuration: 0.3, animations: { 

       self.UserShare.alpha = 0 
       self.UserEdit.alpha = 0 
       self.UserDelete.alpha = 0 

      }) 
     } 
     toggleButton(button: sender as! UIButton, onImage: #imageLiteral(resourceName: "icons8-Plus-48"), offImage: #imageLiteral(resourceName: "AddOn")) 
    } 

当我点击的细胞,它应该返回到原来的非增殖的细胞高度。我的问题是,当我点击单元格返回到非扩展单元格高度时,我也希望三个按钮消失。因此,如果我第三次单击单元格,在单元格的底部,我应该只看到一个按钮。但是当我第三次单击单元格以展开它时,我仍然看到四个按钮。

回答

1

我想尽我所能回答这个问题。只需将您选择的表格视图单元格代码更改为:

if isExpanded && self.selectedIndex == indexPath { 
      cell.CustomView.frame = CGRect(x: 7, y: 8, width: 359, height: 283) 

       self.UserShare.alpha = 0 
       self.UserEdit.alpha = 0 
       self.UserDelete.alpha = 0 


     } 
     else { 
     cell.CustomView.frame = CGRect(x: 7, y: 8, width: 359, height: 115) 

     } 

请让我知道这是否可行。

+0

是的,它工作完美!非常感谢!! – juelizabeth

+0

你可能知道这个问题的解决方案:https://stackoverflow.com/questions/44600680/sending-firebase-value-to-text-fields – juelizabeth

+0

让我看看。 –