我正在尝试快速使用计算器作为 UITextField 的自定义输入视图。
我在我的应用程序中单独定义了一个计算器作为 CalculatorViewController。
我需要访问 InputViewController 中的 UITextField 中的 CalculatorViewController。
我在 InputViewController 中定义了以下属性来访问计算器视图
var textFieldInputView : UIView!{
let calculatorInputController = self.storyboard?.instantiateViewControllerWithIdentifier("calculatorVC") as! calculatorViewController
let calculatorInputView = calculatorInputController.view
return calculatorInputView
}
然后在 textField 中添加以下代码以访问 textFieldInputView
textField.inputView = textFieldInputView
现在,当我单击 textField 时,弹出计算器,如下所示,它不在键盘出现的位置。也没有按钮工作。
如果有人能建议我如何解决这个问题,我们将不胜感激。