danielamitay / DAKeyboardControl

DAKeyboardControl adds keyboard awareness and scrolling dismissal (ala iMessages app) to any view with only 1 line of code.
Other
1.58k stars 214 forks source link

Using dakeyboardcontrol on iPad formsheet. #59

Open DrBeak1 opened 10 years ago

DrBeak1 commented 10 years ago

The issue I'm running into is that when the keyboard is dismissed the toolbar goes down and disappears off the screen. Any ideas on how to fix this?

Thanks in advance.

DrBeak1 commented 10 years ago

I solved this by preventing the toolbar from going lower than the bottom of the current viewControllers View.

float lowestToolbarY = 620.0 - self.commentToolbar.bounds.size.height - self.navigationController.navigationBar.bounds.size.height;

    [self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {
        CGRect toolBarFrame = toolBar.frame;
        toolBarFrame.origin.y = keyboardFrameInView.origin.y - toolBarFrame.size.height;
        if (toolBarFrame.origin.y >=lowestToolbarY) {
            toolBarFrame.origin.y = lowestToolbarY;
        }
        toolBar.frame = toolBarFrame;

        CGRect tableViewFrame = tableView.frame;
        tableViewFrame.size.height = toolBarFrame.origin.y;
        tableView.frame = tableViewFrame;
    }];