PROBLEM : not working in ios 11 (However working in ios 8)
The following code is written in Swift 2.0. But my application is too large to migrate the code at one go and to release an update.
Aim : I want to give a release with xcode 7 but i get a 'developer disk image' when debugging on ios 11. So how can i fix the bug without migrating the code
func viewDidLoad(){
super.baseScrolllView = scrollView
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardAdjust:"), name:UIKeyboardWillShowNotification, object: nil);
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardAdjust:"), name:UIKeyboardWillHideNotification, object: nil);
}
Code in Base class
var keyboardIsVisible = false
var baseScrolllView: UIScrollView!
func keyboardAdjust(notification: NSNotification) {
let info = notification.userInfo!
let keyboardHeight:CGFloat = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue().size.height
let duration:Double = info[UIKeyboardAnimationDurationUserInfoKey] as! Double
var userInfo = notification.userInfo!
var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue()
keyboardFrame = self.view.convertRect(keyboardFrame, fromView: nil)
if notification.name == UIKeyboardWillShowNotification && keyboardIsVisible == false{
keyboardIsVisible = true
UIView.animateWithDuration(duration, animations: { ()
var contentInset:UIEdgeInsets = self.baseScrolllView.contentInset
contentInset.bottom = keyboardFrame.size.height
self.baseScrolllView.contentInset = contentInset
})
}else {
keyboardIsVisible = false
UIView.animateWithDuration(duration, animations: { ()
var contentInset:UIEdgeInsets = UIEdgeInsetsZero
self.baseScrolllView.contentInset = contentInset
})
}
}