New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RefreshControlDesignable example #429
Conversation
Generated by 馃毇 Danger |
For the warning I think it's because we play with the guard !isViewLoaded else {
return
} Adding for the previous ios version is welcome 馃憤 |
Wups, I miss this. You are right the warning has been fixed by putting back the guard, good catch! Thanks |
Added support of There's still a restriction: the user has to add himself the refresh control to its tableView, then call the What do you prefer? I'm ok to change, and I will update the docs following the final decision |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tbaranes it is very good to support refresh control for pre-iOS 10. I have an idea: Can you add it automatically for pre-iOS 10? If we can't, I think we need to add the example code to AnimatableTableView
as a comment.
Apart from that, all good 馃憤, well done 馃挭
CHANGELOG.md
Outdated
@@ -16,8 +16,8 @@ All notable changes to this project will be documented in this file. | |||
[#403](https://github.com/IBAnimatable/IBAnimatable/pull/403) by [@tbaranes](https://github.com/tbaranes) | |||
- Make images of `AnimatableSlider` designable. | |||
[#417](https://github.com/IBAnimatable/IBAnimatable/pull/417) by [@phimage](https://github.com/phimage) | |||
- Add `AnimatableTableViewController` to support `UIRefreshControl` customization. | |||
[#418](https://github.com/IBAnimatable/IBAnimatable/pull/418) by [@phimage](https://github.com/phimage) | |||
- Add `RefreshControlDesignable` to make `UIRefreshControl` customization available in interface builder. Currently supported by `UITableViewController` and `UITableView` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface Builder 馃槄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
override public func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// Install action on refresh | ||
self.refreshControl?.addTarget(self, action: #selector(RefreshTableViewController.refresh(_:)), for: .valueChanged) | ||
self.refreshControl?.addTarget(self, action: #selector(refresh(_:)), for: .valueChanged) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove self
here?
attributes[NSForegroundColorAttributeName] = color | ||
} | ||
refreshControl.attributedTitle = NSAttributedString(string: "\(Int(time))", attributes: attributes ) | ||
|
||
DispatchQueue.main.after(1) { [unowned self] in | ||
self.updateMessage(refreshControl: refreshControl, time: time - 1) | ||
DispatchQueue.main.after(1) { [weak self] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to use [weak self]
or [unowned self]
for DispatchQueue.main
. They are static methods.
} else { | ||
refreshControl = nil | ||
var refreshControl = self.subviews.first { $0 is UIRefreshControl } as? UIRefreshControl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this automatically? For example, we check there is a UIRefreshControl
or not. Add one if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, see my answer below!
} else { | ||
refreshControl = UIRefreshControl() | ||
tableView.addSubview(refreshControl!) | ||
tableView.configureRefreshController() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a comment on https://github.com/IBAnimatable/IBAnimatable/pull/429/files#diff-f56d938957f5c1840f24beee6993086fR43
If we can't do it automatically, we may need to put this code to AnimatableTableView
as a comment for pre-iOS 10.
@JakeLin We can add it automatically, but that means when the user will add a target, he will have to look into IBAnimatable to see how to get it then bind it. The example What do you prefer? Should I still add it automatically? |
@tbaranes I think what you are doing is good. Please merge it when you think it is ready. |
781901d
to
40424d9
Compare
Related to #238 and #425
A few things in this PR:
AnimatableTableView
conforms toRefreshControlDesignable
, iOS10 only, I think we can add a support for lower version, by adding manually the refreshControl. Is it worth it?RefreshControlDesignable
examples in playground:UITableViewController
.UITableView
Seems big, but its mainly storyboards!
Just one thing: I'm getting these warnings in the console for theUITableViewController
example, but don't know why 馃