【问题标题】:animated button in tableViewCelltableViewCell 中的动画按钮
【发布时间】:2017-06-17 09:34:20
【问题描述】:

我有一个自定义的可扩展表格视图。展开后的 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"))
    }

当我单击单元格时,它应该返回到其原始未展开的单元格高度。我的问题是,当我单击单元格返回到未展开的单元格高度时,我还希望三个按钮消失。因此,如果我第三次单击单元格,在单元格底部我应该只看到一个按钮。但是当我第三次单击单元格以展开它时,我仍然看到四个按钮。

【问题讨论】:

    标签: ios swift uitableview


    【解决方案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)
    
            }
    

    如果可行,请告诉我。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-29
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多