【发布时间】:2018-07-26 06:51:41
【问题描述】:
我有一个表单(Eureka 表单,在 UITableView 中),我在 iPad 中显示为 Popover。但是当键盘出现时,Tableview 会向下滚动并隐藏我正在编辑的字段。
当弹出框改变它们的大小时,有没有办法防止这种滚动?还是一种重新关注我正在编辑的字段的方法?
这是主视图控制器中的代码
func presentFormPopover(form: FormViewController) {
let nav = UINavigationController(rootViewController: form)
nav.modalPresentationStyle = .popover
let popover = nav.popoverPresentationController!
popover.sourceRect = CGRect(x: view.center.x, y: view.center.y, width: 0, height: 0)
popover.sourceView = self.view
popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
popover.delegate = self
popover.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
self.present(nav, animated: true, completion: nil)
}
/* Reposition the popover if the screen rotates */
public func popoverPresentationController(_ popoverPresentationController: UIPopoverPresentationController, willRepositionPopoverTo rect: UnsafeMutablePointer<CGRect>, in view: AutoreleasingUnsafeMutablePointer<UIView>) {
let x = popoverPresentationController.presentingViewController.view.center
let newRect = CGRect(x: x.x, y: x.y, width: 0, height: 0)
rect.initialize(to: newRect)
}
这是弹出框形式的代码:
import Eureka
class AddStepTaskFormViewController: FormViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.title = "New Step Task"
form +++ Section("Flowrate")
<<< IntRow(){
$0.title = "Initial Flowrate"
$0.placeholder = "Enter initial flowrate"
}
<<< IntRow(){
$0.title = "Final Flowrate"
$0.placeholder = "Enter final flowrate"
}
+++ Section("Time")
<<< IntRow() {
$0.title = "Minutes"
$0.placeholder = "min"
}
<<< IntRow() {
$0.title = "Seconds"
$0.placeholder = "sec"
}
+++ Section("Repeat")
<<< SwitchRow(){
$0.title = "Repeat"
}
<<< CountDownRow() {
$0.title = "Hello"
}
+++ Section("Section2")
<<< DateRow(){
$0.title = "Date Row"
$0.value = Date(timeIntervalSinceReferenceDate: 0)
}
}
【问题讨论】:
-
显示你的代码。
-
你应该用 Eureka 标签标记这个问题
标签: ios swift keyboard popover eureka-forms