beobachtung von contentSize (CGSize) mit KVO in swift
Ich versuche zu beobachtencollectionView.contentSize
so was
func startObserveCollectionView() {
collectionView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.Old.union(NSKeyValueObservingOptions.New), context: &SearchDasboardLabelContext)
}
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if context == &SearchDasboardLabelContext {
if object === collectionView && keyPath! == "contentSize" {
print(change)
}
}
}
und im xcode terminal habe ich einNSSize
notCGSize
so was
Optional(["old": NSSize: {320, 0}, "new": NSSize: {375, 39.5}, "kind": 1])
In Ziel-C habe ich MethodeCGSizeValue
CGSize newContentSize = [[change objectForKey:NSKeyValueChangeNewKey] CGSizeValue];
Gibt es eine Methode wieCGSizeValue
in swift
Ich habe in swift @ versucvar newContentSize = change[NSKeyValueChangeNewKey]?.CGSizeValue()
aber habe Fehler
could not find member 'CGSizeValue'
not jemandem helfen? Vielen Dan