250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- front-end
- iPhone
- Animation
- 백엔드
- 개발자
- 애니메이션
- 비전공자
- IOS
- 풀스택
- php
- ipad
- effect
- 자바스크립트
- MAC
- javascript
- 비전공 개발자
- HTML
- hover
- css3
- html5
- button
- jQuery
- keyframes
- react
- CSS
- 프론트엔드
- iOS 개발자
- xcode
- image
- SWIFT
Archives
- Today
- Total
비전공자 개발일기
WKWebView OverScroll Disable Setting 본문
728x90
SMALL
<1안>
var isScrolling = false
...
let preferences = WKPreferences()
preferences.javaScriptCanOpenWindowsAutomatically = true
...
let contentController = WKUserContentController()
...
let configuration = WKWebViewConfiguration()
configuration.preferences = preferences
configuration.userContentController = contentController
...
webView = WKWebView(frame: self.view.bounds, configuration: configuration)
...
webView.scrollView.delegate = self
...
webView.scrollView.alwaysBounceVertical = false
webView.scrollView.bounces = false
...
extension ViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard !isScrolling else { return }
isScrolling = true
if scrollView.contentOffset.y <= 0 {
scrollView.contentOffset = CGPoint.zero
}
if scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.bounds.size.height {
let offset = CGPoint(x: scrollView.contentOffset.x, y: scrollView.contentSize.height - scrollView.bounds.size.height)
scrollView.setContentOffset(offset, animated: false)
}
isScrolling = false
}
}
<2안>
...
let preferences = WKPreferences()
preferences.javaScriptCanOpenWindowsAutomatically = true
...
let contentController = WKUserContentController()
...
let configuration = WKWebViewConfiguration()
configuration.preferences = preferences
configuration.userContentController = contentController
...
webView = WKWebView(frame: self.view.bounds, configuration: configuration)
...
webView.scrollView.delegate = self
...
webView.scrollView.alwaysBounceVertical = false
webView.scrollView.bounces = false
if #available(iOS 11.0, *) {
webView.scrollView.contentInsetAdjustmentBehavior = .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
...
728x90
LIST
'SWIFT' 카테고리의 다른 글
Xcode Simulator Cache Delete (0) | 2023.04.21 |
---|---|
Virate Method (0) | 2023.04.14 |
Swift WKWebView Debugging with Safari (0) | 2023.03.09 |
WKWebView URL Query & Header Setting (0) | 2023.03.07 |
SafeArea Color Control (0) | 2023.03.06 |