ios - Detecting Rotation of UIView in Swift -


i have created custom view inherits uiview. need able detect rotation in custom view class.

i have searched online , tried both:

uiapplicationdidchangestatusbarorientationnotification  uideviceorientationdidchangenotification 

i have added init method below show code have tried. tried same code in view controller , worked perfectly.

override init(frame: cgrect) {      super.init(frame: frame)      uidevice.currentdevice().begingeneratingdeviceorientationnotifications()      nsnotificationcenter.defaultcenter().addobserver(         self,         selector: "didrotate:",         name: uiapplicationdidchangestatusbarorientationnotification,         object: nil)      nsnotificationcenter.defaultcenter().addobserver(         self,         selector: "rotated",         name: uideviceorientationdidchangenotification,         object: nil) } 

has else had similar problem, , if did find way solve issue?


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -