gpt4 book ai didi

ios - PushViewController 上的 UINavigation/inputAccessoryView 问题

转载 作者:行者123 更新时间:2023-11-30 13:57:47 34 4
gpt4 key购买 nike

我有 3 个 View Controller 。

顶部 Controller 是 TabViewController 。

在第一个 View Controller 中我这样做:

self.presentViewController(svc, animated: true, completion: nil)

svc 是我的第二个 View Controller 。我也将其传递给 navigationController ,在第二个VC中我使用

self.nav?.pushViewController(cvc, animated: true)
self.dismissViewController

现在, View 被关闭并显示第三个 vc (cvc)但这个函数没有被执行

override var inputAccessoryView: UIView! {

get {
print("inputAccessoryView")
if toolBar == nil {
toolBar = UIToolbar(frame: CGRectMake(0, 0, 0, toolBarMinHeight-0.5))

textView = InputTextView(frame: CGRectZero)
textView.backgroundColor = UIColor(white: 250/255, alpha: 1)
textView.delegate = self
textView.text = "New Message"
textView.textColor = UIColor.lightGrayColor()
textView.font = UIFont.systemFontOfSize(messageFontSize)
textView.layer.borderColor = UIColor(red: 200/255, green: 200/255, blue: 205/255, alpha:1).CGColor
textView.layer.borderWidth = 0.5
textView.layer.cornerRadius = 5
//textView.placeholder = "Message"
textView.scrollsToTop = false
textView.textContainerInset = UIEdgeInsetsMake(4, 3, 3, 3)
toolBar.addSubview(textView)

sendButton = UIButton(type: .System)
sendButton.enabled = false
sendButton.titleLabel?.font = UIFont.boldSystemFontOfSize(17)
sendButton.setTitle("Send", forState: .Normal)
sendButton.setTitleColor(UIColor(red: 142/255, green: 142/255, blue: 147/255, alpha: 1), forState: .Disabled)
sendButton.setTitleColor(UIColor(red: 1/255, green: 122/255, blue: 255/255, alpha: 1), forState: .Normal)
sendButton.contentEdgeInsets = UIEdgeInsets(top: 6, left: 6, bottom: 6, right: 6)
sendButton.addTarget(self, action: "sendAction", forControlEvents: UIControlEvents.TouchUpInside)
toolBar.addSubview(sendButton)

// Auto Layout allows `sendButton` to change width, e.g., for localization.
textView.translatesAutoresizingMaskIntoConstraints = false
sendButton.translatesAutoresizingMaskIntoConstraints = false
toolBar.addConstraint(NSLayoutConstraint(item: textView, attribute: .Left, relatedBy: .Equal, toItem: toolBar, attribute: .Left, multiplier: 1, constant: 8))
toolBar.addConstraint(NSLayoutConstraint(item: textView, attribute: .Top, relatedBy: .Equal, toItem: toolBar, attribute: .Top, multiplier: 1, constant: 7.5))
toolBar.addConstraint(NSLayoutConstraint(item: textView, attribute: .Right, relatedBy: .Equal, toItem: sendButton, attribute: .Left, multiplier: 1, constant: -2))
toolBar.addConstraint(NSLayoutConstraint(item: textView, attribute: .Bottom, relatedBy: .Equal, toItem: toolBar, attribute: .Bottom, multiplier: 1, constant: -8))
toolBar.addConstraint(NSLayoutConstraint(item: sendButton, attribute: .Right, relatedBy: .Equal, toItem: toolBar, attribute: .Right, multiplier: 1, constant: 0))
toolBar.addConstraint(NSLayoutConstraint(item: sendButton, attribute: .Bottom, relatedBy: .Equal, toItem: toolBar, attribute: .Bottom, multiplier: 1, constant: -4.5))
}
return toolBar
}
}

编辑:我也有这个功能,而且仍然

override func canBecomeFirstResponder() -> Bool {
return true
}

有人可以解释一下为什么以及如何解决这个问题吗?

最佳答案

覆盖canBecomeFirstResponder并返回YES

关于ios - PushViewController 上的 UINavigation/inputAccessoryView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33394707/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com