Skip to content

Commit

Permalink
add trigger drop excuting
Browse files Browse the repository at this point in the history
  • Loading branch information
ronghaopger committed Mar 10, 2016
1 parent 8d9f197 commit 9204ec0
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Demo/Demo/EasyPull/EasyObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,9 @@ public class EasyObserver: NSObject {
public func stopExcuting() {
State = .Free
}

public func triggerDropExcuting() {
State = .DropPullingExcuting
self.scrollView?.setContentOffset(CGPoint(x: 0, y: -dropViewSize.height), animated: true)
}
}
6 changes: 6 additions & 0 deletions Demo/Demo/EasyPull/UIScrollView+EasyPull.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ extension UIScrollView {
public func easy_stopDropPull() {
self.Observer.stopExcuting()
}
/**
trigger drop Excuting Directly
*/
public func easy_triggerDropExcuting() {
self.Observer.triggerDropExcuting()
}

/**
add up pull refresh (Manual Mode)
Expand Down
17 changes: 15 additions & 2 deletions Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,19 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour

// MARK: - delegate
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 50.0
return 40.0
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 11 {
//set Excuting directly
tableView.easy_triggerDropExcuting()
}
}

// MARK: - datasource
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
return 25
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
Expand All @@ -114,6 +121,12 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
cell?.titleLabel?.text = " or set your custom view"
case 8:
cell?.titleLabel?.text = " it's easy."
case 10:
cell?.titleLabel?.text = " ____________"
case 11:
cell?.titleLabel?.text = " | click here | "
case 12:
cell?.titleLabel?.text = " |____________|"
default:
cell?.titleLabel?.text = " "
break
Expand Down
2 changes: 1 addition & 1 deletion EasyPull.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "EasyPull"
s.version = "1.0.3"
s.version = "1.1.0"
s.summary = "Let pull-to-refresh Easy for any UIScrollView in Swift"
s.homepage = "https://github.com/ronghaopger/EasyPull"
s.license = "MIT"
Expand Down
Binary file not shown.
5 changes: 5 additions & 0 deletions EasyPull/EasyPull/EasyObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,9 @@ public class EasyObserver: NSObject {
public func stopExcuting() {
State = .Free
}

public func triggerDropExcuting() {
State = .DropPullingExcuting
self.scrollView?.setContentOffset(CGPoint(x: 0, y: -dropViewSize.height), animated: true)
}
}
6 changes: 6 additions & 0 deletions EasyPull/EasyPull/UIScrollView+EasyPull.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ extension UIScrollView {
public func easy_stopDropPull() {
self.Observer.stopExcuting()
}
/**
trigger drop Excuting Directly
*/
public func easy_triggerDropExcuting() {
self.Observer.triggerDropExcuting()
}

/**
add up pull refresh (Manual Mode)
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ Only support Manual Mode(仅支持手动模式)
})
```

Note: You can trigger drop-excuting directly using this method. (用下面这个方法,你可以直接触发下拉刷新操作)

```Swift
func easy_triggerDropExcuting()
```


### Adding Up Pull to Refresh and Load more (添加上拉加载)

Manual Mode(手动模式)
Expand Down Expand Up @@ -67,7 +74,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'EasyPull', '~> 1.0.3'
pod 'EasyPull', '~> 1.1.0'
```

### Source files
Expand Down

0 comments on commit 9204ec0

Please sign in to comment.