當swift3中調用鍵盤隱藏函數時,似乎ScrollView的Insets不會在UIEdgeInsets.Zero上自我更新,但相同的代碼在swift3中完美執行2.2在KeyboardHide函數(SWIFT3)上不調整ScrollView Insets(SWIFT3)
if isViewLoaded && view.window != nil {
if(scrollView != nil)
{
scrollView!.contentInset = UIEdgeInsets.zero
scrollView!.scrollIndicatorInsets = UIEdgeInsets.zero
}
}
或
if isViewLoaded && view.window != nil {
if let userInfo = notification.userInfo {
if let keyboardSize: CGSize = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue.size {
if(scrollView != nil)
{
let contentInsets = UIEdgeInsetsMake(keyboardSize.height, 0.0, 0.0, 0.0)
scrollView!.contentInset = contentInsets
scrollView!.scrollIndicatorInsets = contentInsets
}
self.scrollView?.layoutIfNeeded()
}
}
}
什麼想法..?
有什麼意思,在禁用滾動kindly精心製作.. – iSwift
實際上不需要那條線。您也可以只添加前3行。 @Kedar – KAR
沒有區別 – iSwift