iT邦幫忙

2023 iThome 鐵人賽

DAY 12
0

編輯排序

 @IBAction func sortby(_ sender: Any) {
        
        let controller =  UIAlertController (title: "排序" , message: "新舊" , preferredStyle: .actionSheet)
        let names = [ "新->舊" , "舊->新" ]
        
        for name in names {
            let action = UIAlertAction(title: name, style: .default) { [self] action in
                if action.title == names[0] {
                    
                    self.iteamTabel.sort(by: { m1, m2 in
                        m1.timeStamp > m2.timeStamp
                    })
                    self.tabelview.reloadData()
                    return sortbybool = true
                } else {
                    self.iteamTabel.sort(by: { m1, m2 in
                        m1.timeStamp < m2.timeStamp
                    })
                    self.tabelview.reloadData()
                    return sortbybool = false
                }
            }
            controller.addAction(action)
        }
        let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)
        controller.addAction(cancelAction)
        present(controller, animated: true)
    }

上一篇
Day11 留言板5
下一篇
Day13 推github
系列文
swift 新手路程30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言