anonymous No title
No License Swift
2020年04月22日
Copy
    func scrollToBottom(){
        let withTimeInterval = 0.001
        var elapsedTime = 0.0
        let timeOut = 1.0
        Timer.scheduledTimer(withTimeInterval: withTimeInterval, repeats: true, block: { (timer) in
            elapsedTime = elapsedTime + withTimeInterval
            if(elapsedTime >= timeOut){
                timer.invalidate()
            }
            let tableViews = ViewRetriever.retrieve(parentView: self.window?.rootViewController?.view, inspection: {$0 as? UITableView})
            if !tableViews.isEmpty {
                var rowCount = self.user.items?.count ?? 0
                if rowCount == 0 {
                    rowCount = 1
                }
                let tableView = tableViews[0]
                let loadCount = tableView.numberOfRows(inSection: 0)
                if (loadCount == rowCount){
                    tableView.scrollToRow(at: .init(row: rowCount - 1, section: 0), at: .bottom, animated: true)
                    timer.invalidate()
                }
            }else{
                timer.invalidate()
            }
        })
    }
    func scrollToBottom(){
        let withTimeInterval = 0.001
        var elapsedTime = 0.0
        let timeOut = 1.0
        Timer.scheduledTimer(withTimeInterval: withTimeInterval, repeats: true, block: { (timer) in
            elapsedTime = elapsedTime + withTimeInterval
            if(elapsedTime >= timeOut){
                timer.invalidate()
            }
            let tableViews = ViewRetriever.retrieve(parentView: self.window?.rootViewController?.view, inspection: {$0 as? UITableView})
            if !tableViews.isEmpty {
                var rowCount = self.user.items?.count ?? 0
                if rowCount == 0 {
                    rowCount = 1
                }
                let tableView = tableViews[0]
                let loadCount = tableView.numberOfRows(inSection: 0)
                if (loadCount == rowCount){
                    tableView.scrollToRow(at: .init(row: rowCount - 1, section: 0), at: .bottom, animated: true)
                    timer.invalidate()
                }
            }else{
                timer.invalidate()
            }
        })
    }

年末年始は機械学習・深層学習を勉強しませんか?
No one still commented. Please first comment.
年末年始は機械学習・深層学習を勉強しませんか?
広告
未経験から最短でエンジニアへの転職を目指すなら