Когда пользователь пытается прокручивать таблицу (идет по высоте клавиатуры), она автоматически прокручивается назад в верхнюю часть таблицы, оставляя пользователя не нажатым ни одной из клавиш в нижних строках Таблица. Как отключить автопрокрутку? Обратите внимание, что это отличается от свойства scrollsToTop.UITableView сохраняет autoscrolling to top
import UIKit
class KeyboardViewController: UIInputViewController, UITableViewDelegate, UITableViewDataSource {
var tableView: UITableView = UITableView()
let screenSize: CGRect = UIScreen.mainScreen().bounds
let buttonTitles = [
"XX",
"YY"
]
override func viewDidLoad() {
super.viewDidLoad()
let screenWidth = screenSize.width
let screenHeight = screenSize.height
tableView.frame = CGRectMake(0,0,screenWidth,screenHeight - 40)
tableView.delegate = self
tableView.dataSource = self
tableView.registerClass(UITableViewCell.self,forCellReuseIdentifier: "cell")
self.view.addSubview(tableView)
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.buttonTitles.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell
cell.textLabel?.text = self.buttonTitles[indexPath.row]
cell.textLabel?.textAlignment = .Center
cell.textLabel?.font = UIFont(name: "Helvetica Neue", size: 14)
cell.textLabel?.textColor = UIColor.whiteColor()
cell.textLabel?.numberOfLines = 0
cell.backgroundColor = UIColor(red: 176/255, green: 15/255, blue: 15/255, alpha: 1.0)
cell.preservesSuperviewLayoutMargins = false
cell.layoutMargins = UIEdgeInsetsZero
cell.separatorInset = UIEdgeInsetsZero
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var string = buttonTitles[indexPath.row]
(textDocumentProxy as! UIKeyInput).insertText("\(string)")
}
Показать больше кода. Не должно быть неправильного внешнего видаDidLoad. – kostek
Вы устанавливаете контентOffset или contentInsets в любом месте этого viewController? – villy393
@kostek - спасибо - просто предоставлено все в файле .swift – vk2015