在一个视图中,我想在键盘出现时使textView和工具栏上升,但是我有一些问题,因为在移动它们之后。问题是工具栏上的按钮不能再被按下了
我必须提一下,我在视图中添加了这两个项目[在viewController中 - 页面的主视图]
以下是我的尝试:
func keyboardDidShow(notification :NSNotification){
var c = notification.userInfo as NSDictionary
var point:NSValue = NSValue(nonretainedObject: c.objectForKey(UIKeyboardFrameEndUserInfoKey))
let s:NSValue = c.valueForKey(UIKeyboardFrameEndUserInfoKey) as NSValue;
let rect :CGRect = s.CGRectValue();
var frame = self.messageText.frame
var toolbarFrame = self.toolbar.frame
var textFrame = self.textfieldFrame.frame
var offset = (rect.height - ((self.view.frame.height - self.messageText.frame.origin.y) + self.messageText.frame.size.height)) + 80
//frame is the frame of the textview toolbarframe of the toolbar and textframe of the view
frame.origin.y = self.messageText.frame.origin.y - rect.height
toolbarFrame.origin.y = self.toolbar.frame.origin.y - rect.height
textFrame.origin.y = self.textfieldFrame.frame.origin.y - rect.height
UIView.animateWithDuration(0.3, animations: {
self.messageText.frame = frame
self.toolbar.frame = toolbarFrame
self.toolbar.multipleTouchEnabled = true
var items = self.toolbar.items
for item in items {
var button :UIBarButtonItem = item as UIBarButtonItem
}
})
UIView.commitAnimations()
}
你能解释一下我在这里做错了吗?