Created
March 1, 2016 21:19
-
-
Save Streek/7603e71bc38d107c37f8 to your computer and use it in GitHub Desktop.
Web View Pull To Refresh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
addPullToRefreshToWebView() | |
} | |
func addPullToRefreshToWebView(){ | |
var refreshController:UIRefreshControl = UIRefreshControl() | |
refreshController.bounds = CGRectMake(0, 50, refreshController.bounds.size.width, refreshController.bounds.size.height) // Change position of refresh view | |
refreshController.addTarget(self, action: Selector("refreshWebView:"), forControlEvents: UIControlEvents.ValueChanged) | |
refreshController.attributedTitle = NSAttributedString(string: "Pull down to refresh...") | |
YourWebView.scrollView.addSubview(refreshController) | |
} | |
func refreshWebView(refresh:UIRefreshControl){ | |
YourWebView.reload() | |
refresh.endRefreshing() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment