我想使用這個插件的刷新操作:https://github.com/entotsu/PullToBounce拉刷新插件:PullToBounce包裝的UIScrollView
一,問題是我無法理解他的解釋。
Explanation given on the github
tableView.frame = yourFrame - >的tableView在我的情況
yourFrame等於scrollView.frame - >我不知道它是什麼。主框架?我必須創建另一個框架?
bodyView.addSubview(tableViewWrapper) - > bodyView?主框架在這裏?或另一個框架?
這是我現在的scrollView的代碼。任何有關如何使用通過故事板製作的scrollView實現此插件的幫助。
class ProfileViewController: UIViewController {
@IBOutlet weak var scrollView: UIScrollView!
func makeMock() {
let headerView = UIView()
headerView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: 64)
headerView.backgroundColor = UIColor.lightBlue
self.view.addSubview(headerView)
let headerLine = UIView()
headerLine.frame = CGRect(x: 0, y: 0, width: 120, height: 8)
headerLine.layer.cornerRadius = headerLine.frame.height/2
headerLine.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.8)
headerLine.center = CGPoint(x: headerView.frame.center.x, y: 20 + 44/2)
headerView.addSubview(headerLine)
}
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.blue
let bodyView = UIView()
bodyView.frame = scrollView.frame
bodyView.frame.y += 20 + 44
self.view.addSubview(bodyView)
let tableViewWrapper = PullToBounceWrapper(scrollView: scrollView)
bodyView.addSubview(tableViewWrapper)
tableViewWrapper.didPullToRefresh = {
NSTimer.schedule(delay: 2) { timer in
tableViewWrapper.stopLoadingAnimation()
}
}
makeMock()
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}
}
有一件事,我注意到的是,有是禁用我認爲它並滾動它在我的滾動視圖的頂視圖。請幫助這裏需要。
問候,
HARY
我看過這個例子。他通過swift文件實現了他的tableView。我已經通過故事板實現了我的scrollView。它已準備好實際上。 SampleTableView是一個類,他創建他的表視圖。我已經有了scrollView。檢查我的代碼,我想我是按他的說法做的。感謝您的答覆 ! –
你是說tableView是我的scrollView,那麼你的框架在這裏是什麼,然後......我沒有看到這一點。 「scrollView.frame = yourFrame」? –
你必須通過實施 FUNC scrollViewDidScroll符合'UIScrollViewDelegate'(滾動視圖:UIScrollView的){} FUNC scrollViewWillEndDragging(滾動視圖:UIScrollView的!速度:CGPoint,INOUT targetContentOffset:CGPoint){} 只是製作參考插座不會讓你的類成爲UIScrollView。 – Dershowitz123