Closed D2Jgs closed 4 years ago
I found the solution for the problem in one of the closed issues.
it was giving the background view a height.
How can I add a keyboardTrackingView in such a scenario?
I am using a search bar in the bottom message viewcontroller.
You can an assign the keyboardTrackingView
property on the segue to get basic keyboard avoidance.
Could you please help me figure out where and how to access that property.
Below is code for the bottom message segue :-
class SwiftMessagesBottomSegue: SwiftMessagesSegue {
override public init(identifier: String?, source: UIViewController, destination: UIViewController) {
super.init(identifier: identifier, source: source, destination: destination)
messageView.backgroundHeight = 200
configure(layout: .bottomMessage)
}
}
Below is the tableView Controller being called
class SearchTableViewController: UITableViewController {
let test : [String] = ["Test1","Test2","Test3","Test1","Test2","Test3","Test1","Test2","Test3","Test1","Test2","Test3"]
override func viewDidLoad() {
super.viewDidLoad()
tableView.separatorStyle = .none
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return test.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "testTableCell", for: indexPath) as! searchTableViewCell
cell.textDataLabel.text = test[indexPath.row]
return cell
}
Thank you.
class SwiftMessagesBottomSegue: SwiftMessagesSegue {
override public init(identifier: String?, source: UIViewController, destination: UIViewController) {
super.init(identifier: identifier, source: source, destination: destination)
messageView.backgroundHeight = 200
configure(layout: .bottomMessage)
keyboardTrackingView = KeyboardTrackingView()
}
}
Please try to use proper Markdown format for your code. I edited your post to make it readable.
There is no such property as keyboardTrackingView in SwiftMessagesSegue. It shows the error "Use of unresolved identifier 'keyboardTrackingView'"
Is it only available for swift 5?
If that is the case then it is fine because I am working on Swift 4.2.
It was added in SwiftMessages 7.0.0, which is Swift 5. Sorry.
Ok. No problem. Thanks anyways
I created a dynamic table view using the example of the bottom message segue you provided, but it does not work.
The "override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell " never gets called.
Is it not supposed to work with dynamic table views?