我想使用这个插件的刷新操作: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