https://github.com/cxa/webviewcontentpositioner
Scroll position maintainer for UIWebView.
https://github.com/cxa/webviewcontentpositioner
Last synced: 11 months ago
JSON representation
Scroll position maintainer for UIWebView.
- Host: GitHub
- URL: https://github.com/cxa/webviewcontentpositioner
- Owner: cxa
- License: other
- Created: 2016-01-07T15:29:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-16T18:48:18.000Z (over 9 years ago)
- Last Synced: 2025-05-04T20:40:54.775Z (about 1 year ago)
- Language: Swift
- Size: 15.6 KB
- Stars: 26
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebViewContentPositioner
`WebViewContentPositioner` is a scroll position maintainer for `UIWebView`. Never losing scroll position when view resizing on device rotation, split window changing, etc., even if view restoration.
## How to Use
1. Add the `WebViewContentPositioner` repository as a submodule of your application’s repository.
2. Drag and drop `WebViewContentPositioner.xcodeproj` into your application’s Xcode project or workspace.
3. On the “General” tab of your application target’s settings, add `WebViewContentPositioner.framework` to the “Embedded Binaries” section.
Or, If you would prefer to use Carthage or CocoaPods, please pull request.
`WebViewContentPositioner` tracks scroll position automatically for device rotation and split window size changing (by swizzling `- traitCollectionDidChange:`). Plus, you can save current position as a JSON String by `[UIWebView -currentPosition]` and restore by `[UIWebView -restorePosition:]` if needed.
See a real usage inside `Demo` folder.
## Gotcha
`WebViewContentPositioner` may fail if web page contains position-fixed elements on top. It's not intent to be used in a browser but EPUB reader like project.
## About Me
* Twitter: [@_cxa](https://twitter.com/_cxa)
* Apps available in App Store:
* PayPal: xianan.chen+paypal 📧 gmail.com, buy me a cup of coffee if you find it's useful for you.
## License
`DOMContentLoadedDelegate` is released under the MIT license. In short, it's royalty-free but you must keep the copyright notice in your code or software distribution.
Some functions in JS are derived from [Firebug](https://github.com/firebug/firebug), it is free and open source software distributed under the BSD License.