LoginSignup
6
7

More than 5 years have passed since last update.

Swift 3 + iOS 10でUIScrollView#contentOffsetの変更を監視する

Last updated at Posted at 2016-10-25

ややてこずったので、世界平和のために軌跡を残します。

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    if (keyPath == "contentOffset") {
        if let value = change?[NSKeyValueChangeKey.newKey] as? NSValue {
            let contentOffset = value.cgPointValue
            // あとは煮るなり焼くなり
        }
    }
}

前はNSNumber -> CGPointValueで取れてたんですが、NSValueじゃないとだめになったようです。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7