从Tispr卡堆栈中删除卡

时间:2017-07-04 13:01:51

标签: ios swift3 uicollectionview

我想用Thispr Card执行删除功能。你能指导我怎么做吗?我从堆栈中删除了一个对象后重新加载了视图,但它正在为我崩溃。

进入下一个视图并执行删除操作后。然后当我回来时我的堆栈应该刷新。在viewdidappear()中我做了这个

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(true)



    if(dm.cardshouldRefresh || isFirsttimeLoad)
    {

        com.showProgress()

        self.getAuthorizations() { (status) in

            self.dm.cardshouldRefresh=false
            self.isFirsttimeLoad=false
            self.com.removeProgress()
            if (status)
            {
                self.setupCardView()

            }

        }
    }

    else
    {
        print(arrayAuthorization)

    }



}

func makecollectionViewEmpty()
{
    arrayAuthorization.removeAll()
    vwBtnPanelBottom.removeFromSuperview()
    self.collectionView?.reloadData()
}

但是一旦我尝试在加载后滑动,这就会崩溃。 请帮我。 感谢

1 个答案:

答案 0 :(得分:0)

TisprCardStackExample项目中添加以下方法,您将获得删除方法。

<强> TisprCardStackDemoViewController.swift

//method to remove card
@IBAction func addNewCards(_ sender: AnyObject) {
    countOfCards -= 1
    if(countOfCards >= 0){
        cardWasRemoved()
    }
}

<强> TisprCardStackViewController.swift

open func cardWasRemoved() {
    if layout.newCardShouldAppearOnTheBottom {
        layout.cardDidRemoved(0)
    } else {
        layout.cardDidRemoved(numberOfCards() - 1)
    }
}

<强> TisprCardStackViewLayout.swift

func cardDidRemoved(_ newCardIndex:Int) {        
    collectionView?.performBatchUpdates({ [weak self] _ in
        self?.collectionView?.deleteItems(at: [IndexPath(item: newCardIndex, section: 0)])
        }, completion: { _ in
    })
}
相关问题