Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vikrant-Ios/20995328ebd0a4726c28da2f4ea7f554 to your computer and use it in GitHub Desktop.
Save vikrant-Ios/20995328ebd0a4726c28da2f4ea7f554 to your computer and use it in GitHub Desktop.
Table view Next Textfield and keyboard open and close
import Foundation
import UIKit
extension UITableView {
func nextResponder(index: Int){
var currIndex = -1
for i in index+1..<index+100{
if let view = self.superview?.superview?.viewWithTag(i){
view.becomeFirstResponder()
currIndex = i
break
}
}
let ind = IndexPath(row: currIndex - 100, section: 0)
if let nextCell = self.cellForRow(at: ind){
self.scrollRectToVisible(nextCell.frame, animated: true)
}
}
func keyboardRaised(height: CGFloat){
self.contentInset.bottom = height
self.scrollIndicatorInsets.bottom = height
}
func keyboardClosed(){
self.contentInset.bottom = 0
self.scrollIndicatorInsets.bottom = 0
self.scrollRectToVisible(CGRect.zero, animated: true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment