0

In a view I want to make a textView and a toolbar go up when the keyboard appears but I am having some issues because after moving them up.The issue is that the buttons on the toolbar can not be pressed anymore

I have to mention that I added these two items inside a view[that is inside a viewController-the main view of the page]

Here is what I tried:

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()
}

Can you please explain what I'm doing wrong here?

tudoricc
  • 709
  • 1
  • 12
  • 31

0 Answers0