Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit f5bc559

Browse files
Fix淘宝下拉刷新问题
1 parent a48521d commit f5bc559

7 files changed

Lines changed: 63 additions & 34 deletions

File tree

PullToRefreshKit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
52261F131D36879C00161ADF /* DefaultBannerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52261F121D36879C00161ADF /* DefaultBannerController.swift */; };
1515
5238C7D11D373B3300B3B4FE /* DefaultScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7D01D373B3300B3B4FE /* DefaultScrollViewController.swift */; };
1616
5238C7D31D37427C00B3B4FE /* TaoBaoRefreshHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7D21D37427C00B3B4FE /* TaoBaoRefreshHeader.swift */; };
17-
5238C7D51D37449800B3B4FE /* CustomHeaderTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7D41D37449800B3B4FE /* CustomHeaderTableViewController.swift */; };
18-
5238C7F51D3758A900B3B4FE /* CustomFooterTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7F41D3758A900B3B4FE /* CustomFooterTableViewController.swift */; };
17+
5238C7D51D37449800B3B4FE /* TaobaoTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7D41D37449800B3B4FE /* TaobaoTableViewController.swift */; };
18+
5238C7F51D3758A900B3B4FE /* WeiBoRefreshHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7F41D3758A900B3B4FE /* WeiBoRefreshHeader.swift */; };
1919
5238C7FE1D3763BA00B3B4FE /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7F81D3763BA00B3B4FE /* Const.swift */; };
2020
5238C7FF1D3763BA00B3B4FE /* Footer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7F91D3763BA00B3B4FE /* Footer.swift */; };
2121
5238C8001D3763BA00B3B4FE /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5238C7FA1D3763BA00B3B4FE /* Header.swift */; };
@@ -35,6 +35,7 @@
3535
52E8FB451D336E26000D0BF1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52E8FB431D336E26000D0BF1 /* Main.storyboard */; };
3636
52E8FB471D336E26000D0BF1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 52E8FB461D336E26000D0BF1 /* Assets.xcassets */; };
3737
52E8FB4A1D336E26000D0BF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52E8FB481D336E26000D0BF1 /* LaunchScreen.storyboard */; };
38+
52FA97A41D3882190021D77F /* CustomBaseTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FA97A31D3882190021D77F /* CustomBaseTableViewController.swift */; };
3839
/* End PBXBuildFile section */
3940

4041
/* Begin PBXFileReference section */
@@ -45,8 +46,8 @@
4546
52261F121D36879C00161ADF /* DefaultBannerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultBannerController.swift; sourceTree = "<group>"; };
4647
5238C7D01D373B3300B3B4FE /* DefaultScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultScrollViewController.swift; sourceTree = "<group>"; };
4748
5238C7D21D37427C00B3B4FE /* TaoBaoRefreshHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaoBaoRefreshHeader.swift; sourceTree = "<group>"; };
48-
5238C7D41D37449800B3B4FE /* CustomHeaderTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomHeaderTableViewController.swift; sourceTree = "<group>"; };
49-
5238C7F41D3758A900B3B4FE /* CustomFooterTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomFooterTableViewController.swift; sourceTree = "<group>"; };
49+
5238C7D41D37449800B3B4FE /* TaobaoTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaobaoTableViewController.swift; sourceTree = "<group>"; };
50+
5238C7F41D3758A900B3B4FE /* WeiBoRefreshHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeiBoRefreshHeader.swift; sourceTree = "<group>"; };
5051
5238C7F81D3763BA00B3B4FE /* Const.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Const.swift; path = Source/Classes/Const.swift; sourceTree = SOURCE_ROOT; };
5152
5238C7F91D3763BA00B3B4FE /* Footer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Footer.swift; path = Source/Classes/Footer.swift; sourceTree = SOURCE_ROOT; };
5253
5238C7FA1D3763BA00B3B4FE /* Header.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Header.swift; path = Source/Classes/Header.swift; sourceTree = SOURCE_ROOT; };
@@ -68,6 +69,7 @@
6869
52E8FB461D336E26000D0BF1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6970
52E8FB491D336E26000D0BF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7071
52E8FB4B1D336E26000D0BF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
72+
52FA97A31D3882190021D77F /* CustomBaseTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomBaseTableViewController.swift; sourceTree = "<group>"; };
7173
/* End PBXFileReference section */
7274

7375
/* Begin PBXFrameworksBuildPhase section */
@@ -133,9 +135,10 @@
133135
52BB292C1D364C390091F36B /* Custom */ = {
134136
isa = PBXGroup;
135137
children = (
138+
52FA97A31D3882190021D77F /* CustomBaseTableViewController.swift */,
136139
5238C7D21D37427C00B3B4FE /* TaoBaoRefreshHeader.swift */,
137-
5238C7D41D37449800B3B4FE /* CustomHeaderTableViewController.swift */,
138-
5238C7F41D3758A900B3B4FE /* CustomFooterTableViewController.swift */,
140+
5238C7D41D37449800B3B4FE /* TaobaoTableViewController.swift */,
141+
5238C7F41D3758A900B3B4FE /* WeiBoRefreshHeader.swift */,
139142
);
140143
name = Custom;
141144
sourceTree = "<group>";
@@ -258,7 +261,7 @@
258261
buildActionMask = 2147483647;
259262
files = (
260263
5238C8011D3763BA00B3B4FE /* Left.swift in Sources */,
261-
5238C7F51D3758A900B3B4FE /* CustomFooterTableViewController.swift in Sources */,
264+
5238C7F51D3758A900B3B4FE /* WeiBoRefreshHeader.swift in Sources */,
262265
52BB29281D3644D00091F36B /* SectionModel.swift in Sources */,
263266
5238C8021D3763BA00B3B4FE /* PullToRefresh.swift in Sources */,
264267
52261F131D36879C00161ADF /* DefaultBannerController.swift in Sources */,
@@ -268,8 +271,9 @@
268271
5238C7FF1D3763BA00B3B4FE /* Footer.swift in Sources */,
269272
52BB29341D3655B90091F36B /* Util.swift in Sources */,
270273
5238C8001D3763BA00B3B4FE /* Header.swift in Sources */,
271-
5238C7D51D37449800B3B4FE /* CustomHeaderTableViewController.swift in Sources */,
274+
5238C7D51D37449800B3B4FE /* TaobaoTableViewController.swift in Sources */,
272275
52261F0B1D36730F00161ADF /* DefaultCollectionViewController.swift in Sources */,
276+
52FA97A41D3882190021D77F /* CustomBaseTableViewController.swift in Sources */,
273277
52261F0D1D36832600161ADF /* ConfigHeaderFooterController.swift in Sources */,
274278
52C0E4881D3726EB00618231 /* ConfigBannerController.swift in Sources */,
275279
52BB29321D364E490091F36B /* DefaultTableViewController.swift in Sources */,
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
//
2-
// CustomHeaderTableViewController.swift
2+
// CustomBaseTableViewController.swift
33
// PullToRefreshKit
44
//
5-
// Created by huangwenchen on 16/7/14.
5+
// Created by huangwenchen on 16/7/15.
66
// Copyright © 2016年 Leo. All rights reserved.
77
//
88

9-
import Foundation
109
import UIKit
11-
class CustomHeaderTableViewController:UITableViewController{
10+
11+
class CustomBaseTableViewController: UITableViewController {
1212
var models = [1,2,3,4,5,6,7,8,9,10]
1313
override func viewDidLoad() {
1414
super.viewDidLoad()
1515
self.tableView.tableFooterView = UIView(frame: CGRectZero)
16-
17-
let taobaoHeader = TaoBaoRefreshHeader(frame: CGRectMake(0,0,CGRectGetWidth(self.view.bounds),80))
18-
self.tableView.setUpHeaderRefresh(taobaoHeader) { [weak self] in
19-
delay(1.5, closure: {
20-
self?.models = (self?.models.map({_ in random100()}))!
21-
self?.tableView.reloadData()
22-
self?.tableView.endHeaderRefreshing(.Success)
23-
})
24-
}
2516
}
2617
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
2718
return models.count
@@ -38,6 +29,6 @@ class CustomHeaderTableViewController:UITableViewController{
3829
return cell!
3930
}
4031
deinit{
41-
print("Deinit of DefaultTableViewController")
32+
print("Deinit of \(NSStringFromClass(self.dynamicType))")
4233
}
43-
}
34+
}

PullToRefreshKit/MainViewController.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import UIKit
1010
import AudioToolbox
1111

12-
// 如果你喜欢这个库,一个★就是对我最好的支持,项目地址 https://github.com/LeoMobileDeveloper/PullToRefreshKit
12+
/*
13+
如果你喜欢这个库,一个★就是对我最好的支持,项目地址 https://github.com/LeoMobileDeveloper/PullToRefreshKit
14+
*/
1315
class MainViewController: UITableViewController {
1416
var models = [SectionModel]()
1517
override func viewDidLoad() {
@@ -24,7 +26,7 @@ class MainViewController: UITableViewController {
2426
let section2 = SectionModel(rowsCount: 1,
2527
sectionTitle:"自定义",
2628
rowsTitles: ["淘宝下拉刷新",],
27-
rowsTargetControlerNames:["CustomHeaderTableViewController"])
29+
rowsTargetControlerNames:["TaobaoTableViewController"])
2830
models.append(section0)
2931
models.append(section1)
3032
models.append(section2)

PullToRefreshKit/TaoBaoRefreshHeader.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
1313
private let circleLayer = CAShapeLayer()
1414
private let arrowLayer = CAShapeLayer()
1515
private let textLabel = UILabel()
16-
16+
private let strokeColor = UIColor(red: 135.0/255.0, green: 136.0/255.0, blue: 137.0/255.0, alpha: 1.0)
1717
override init(frame: CGRect) {
1818
super.init(frame: frame)
1919
setUpCircleLayer()
2020
setUpArrowLayer()
2121
textLabel.frame = CGRectMake(CGRectGetWidth(self.bounds)/2 - 30, CGRectGetHeight(self.bounds)/2 - 20,120, 40)
2222
textLabel.textAlignment = .Center
23+
textLabel.textColor = UIColor.lightGrayColor()
2324
textLabel.font = UIFont.systemFontOfSize(14)
2425
textLabel.text = "下拉即可刷新..."
2526
self.addSubview(textLabel)
2627
}
2728
func setUpArrowLayer(){
2829
let bezierPath = UIBezierPath()
29-
bezierPath.moveToPoint(CGPointMake(20, 10))
30-
bezierPath.addLineToPoint(CGPointMake(20, 30))
31-
bezierPath.addLineToPoint(CGPointMake(25,25))
32-
bezierPath.moveToPoint(CGPointMake(20, 30))
33-
bezierPath.addLineToPoint(CGPointMake(15, 25))
30+
bezierPath.moveToPoint(CGPointMake(20, 15))
31+
bezierPath.addLineToPoint(CGPointMake(20, 25))
32+
bezierPath.addLineToPoint(CGPointMake(25,20))
33+
bezierPath.moveToPoint(CGPointMake(20, 25))
34+
bezierPath.addLineToPoint(CGPointMake(15, 20))
3435
self.arrowLayer.path = bezierPath.CGPath
35-
self.arrowLayer.strokeColor = UIColor.blackColor().CGColor
36+
self.arrowLayer.strokeColor = UIColor.lightGrayColor().CGColor
3637
self.arrowLayer.fillColor = UIColor.clearColor().CGColor
3738
self.arrowLayer.lineWidth = 1.0
3839
self.arrowLayer.lineCap = kCALineCapRound
@@ -43,12 +44,12 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
4344
}
4445
func setUpCircleLayer(){
4546
let bezierPath = UIBezierPath(arcCenter: CGPointMake(20, 20),
46-
radius: 15.0,
47+
radius: 12.0,
4748
startAngle:CGFloat(-M_PI/2),
4849
endAngle: CGFloat(M_PI_2 * 3),
4950
clockwise: true)
5051
self.circleLayer.path = bezierPath.CGPath
51-
self.circleLayer.strokeColor = UIColor.blackColor().CGColor
52+
self.circleLayer.strokeColor = UIColor.lightGrayColor().CGColor
5253
self.circleLayer.fillColor = UIColor.clearColor().CGColor
5354
self.circleLayer.strokeStart = 0.05
5455
self.circleLayer.strokeEnd = 0.05
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// TaobaoTableViewController.swift
3+
// PullToRefreshKit
4+
//
5+
// Created by huangwenchen on 16/7/14.
6+
// Copyright © 2016年 Leo. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
class TaobaoTableViewController:CustomBaseTableViewController{
12+
override func viewDidLoad() {
13+
super.viewDidLoad()
14+
//Setup
15+
self.tableView.backgroundColor = UIColor(red: 232.0/255.0, green: 234.0/255.0, blue: 235.0/255.0, alpha: 1.0)
16+
let taobaoHeader = TaoBaoRefreshHeader(frame: CGRectMake(0,0,CGRectGetWidth(self.view.bounds),60))
17+
self.tableView.setUpHeaderRefresh(taobaoHeader) { [weak self] in
18+
delay(1.5, closure: {
19+
self?.models = (self?.models.map({_ in random100()}))!
20+
self?.tableView.reloadData()
21+
self?.tableView.endHeaderRefreshing(.Success)
22+
})
23+
}
24+
}
25+
}
File renamed without changes.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ self.tableView.setUpHeaderRefresh { [weak self] in
2222
- iOS 8
2323
- Swift 2
2424

25+
支持
26+
27+
- UITableView
28+
- UICollectionView
29+
- UIScrollView
30+
- UIWebView(TODO)
2531

2632

2733
## 安装

0 commit comments

Comments
 (0)