Last active
May 16, 2018 06:38
-
-
Save vikrant-Ios/20995328ebd0a4726c28da2f4ea7f554 to your computer and use it in GitHub Desktop.
Table view Next Textfield and keyboard open and close
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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