Iphone 键盘顶部的UIToolbar:是否更改框架?

Iphone 键盘顶部的UIToolbar:是否更改框架?,iphone,uitoolbar,Iphone,Uitoolbar,我将一个UIToolbar设置为UITextView的inputAccessoryView。编辑时,这将显示键盘顶部的工具栏。然而,我在旋转设备时遇到了一个问题:工具栏的高度应该变小一点(32像素vs 44像素)。当我只是更新工具栏的高度时,工具栏和键盘之间会有一点空白: 因此,我使用了-didRotateFromInterfaceOrientation:来更新原点,然后在从纵向旋转到横向旋转时,它会起作用。但是,当向上旋转时,工具栏太低12像素,与键盘重叠: 到那时,原点又是(0,0),设

我将一个
UIToolbar
设置为
UITextView
inputAccessoryView
。编辑时,这将显示键盘顶部的工具栏。然而,我在旋转设备时遇到了一个问题:工具栏的高度应该变小一点(32像素vs 44像素)。当我只是更新工具栏的高度时,工具栏和键盘之间会有一点空白:

因此,我使用了
-didRotateFromInterfaceOrientation:
来更新原点,然后在从纵向旋转到横向旋转时,它会起作用。但是,当向上旋转时,工具栏太低12像素,与键盘重叠:


到那时,原点又是(0,0),设置负值没有帮助。关于如何使工具栏工作以使其改变大小且永不重叠的任何建议?

您可以在旋转期间使用自动调整大小来渲染控件,而不是计算原点和大小

请参见本教程


我想这可以给你一个提示。

在旋转过程中,你可以使用自动调整大小来渲染控件,而不是计算原点和大小

请参见本教程


我想这可以给你一个提示。

我通过在
中调用
[textView辞职FirstResponder]
-willRotateToInterfaceOrientation:duration:
[textView becomeFirstResponder]
中调用
-didRotateFromInterfaceOrientation:
来修复它。系统似乎正确地调整了框架

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    didShowKeyboard = [self.textView isFirstResponder];

    [self.textView resignFirstResponder];
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    CGRect toolbarFrame = [self.navigationController.toolbar bounds];
    self.keyboardToolbar.frame = toolbarFrame;

    if (didShowKeyboard)
        [self.textView becomeFirstResponder];
}

我通过调用
-willRotateToInterfaceOrientation:duration:
中的
[textView辞职FirstResponder]
-didRotateFromInterfaceOrientation:
中的
[textView becomeFirstResponder]
解决了这个问题。系统似乎正确地调整了框架

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    didShowKeyboard = [self.textView isFirstResponder];

    [self.textView resignFirstResponder];
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    CGRect toolbarFrame = [self.navigationController.toolbar bounds];
    self.keyboardToolbar.frame = toolbarFrame;

    if (didShowKeyboard)
        [self.textView becomeFirstResponder];
}

我试着在工具栏上使用自动调整大小和
inputAccessoryView
但它不起作用。。我也尝试了视图交换,但得到了奇怪的结果。如何将一个工具栏与另一个工具栏交换?只是更新
inputAccessoryView
没有帮助,而且
[工具栏从SuperView移除]
也没有。我尝试在工具栏和
inputAccessoryView上使用自动调整大小功能,但没有起作用。。我也尝试了视图交换,但得到了奇怪的结果。如何将一个工具栏与另一个工具栏交换?仅仅更新
inputAccessoryView
没有帮助,而且
[工具栏从超级视图中移除]
也没有帮助。