当我尝试从InputView上的另一个UiViewController调用UiViewController时遇到问题。 例如:
我有班主要:
class HomeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, RunKeyboardDelegate
{
override func viewDidLoad() {
super.viewDidLoad()
let view1 = self.storyboard!.instantiateViewControllerWithIdentifier("RunKeyboardViewController") as! RunKeyboardViewController
view1.delegate = self
txtRunPaciente.inputView = view1.view
}
}
inputView的类:
protocol RunKeyboardDelegate:class
{
func runChange(sRun: String?)
}
类RunKeyboardViewController:UIViewController {
weak var delegate : RunKeyboardDelegate?
var sRun: String = ""
override func viewDidLoad()
{
super.viewDidLoad()
println("TECLADO INI")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func buttonAction(sender: UIButton)
{
/* sRun = sRun + "1"
self.delegate?.runChange(sRun)
*/
if(sender.tag == 1)
{
println("BTN1")
}
}
@IBAction func btn2Action(sender: AnyObject)
{
/*
sRun = sRun + "2"
self.delegate?.runChange(sRun)
*/
println("BTN1")
}
}
当我将故事板按钮与动作链接时,单击时,应用程序崩溃并返回此消息:无法识别的选择器发送到实例0x7fe82d14d5f0。