2016-12-19 25 views
0

我想用swift創建可擴展部分。例如在下圖中,Microsoft Outlook IOS應用程序具有可擴展部分。Swift - TableView如何創建可擴展部分

enter image description here

當您單擊的部分,它看起來像下面。

enter image description here

這部分需要額外的代碼或Xcode中已經有這個功能嗎?提前致謝。

回答

0

您需要爲您創建的自定義部分創建一個委託,將其分配給ViewController,並在委託方法中用戶點擊時調用此委託。

insertRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) 

當用戶再次點擊該部分時,檢查該部分是否打開,如果是,則調用此方法。

deleteRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) 

並且不要忘記在這些方法之後調用tableView.reloadData()

0

我最近在我的一個項目中使用過同樣的東西,但它在objective-c中,我知道一件事會幫助你。請看看,

Swift Expandable Section

我鋤它會幫助你。

謝謝。