相关疑难解决方法(0)

在iOS 8中更改inputAccessoryView的框架

很长一段时间潜伏 - 第一次海报!

我在重建UITextView像WhatsApp这样的酒吧时遇到了问题.

我正在使用自定义UIView子类,并懒惰地实例化它:

- (UIView *)inputAccessoryView

并返回YES:

- (BOOL)canBecomeFirstResponder

现在,我想改变的大小inputAccessoryView时,UITextView在规模的增长.在iOS 7上,我只是改变所述视图框架的大小 - 而不是它的原点 - 然后调用reloadInputViews它会起作用:视图将向上移动,使其在键盘上方完全可见.

但是,在iOS 8上,这不起作用.使其工作的唯一方法是还将帧的原点更改为负值.这样会很好,除了它会产生一些奇怪的错误:例如,UIView在输入任何文本时返回到"原始"框架.

有什么我想念的吗?我非常肯定WhatsApp使用它inputAccessoryView是因为它们在拖动时解除键盘的方式 - 仅在最新版本的应用程序中.

如果你能帮助我,请告诉我!或者,如果有任何测试,您希望我运行!

谢谢!:)

顺便说一下,这是我用来更新自定义UIView高度的代码composeBar:

// ComposeBar frame size
CGRect frame = self.composeBar.frame;
frame.size.height += heightDifference;
frame.origin.y -= heightDifference;
self.composeBar.frame = frame;
[self.composeBar.textView reloadInputViews]; // Tried with this
[self reloadInputViews];                     // and this
Run Code Online (Sandbox Code Playgroud)

编辑:完整源代码可在@ https://github.com/manuelmenzella/SocketChat-iOS获得

objective-c ios inputaccessoryview ios8

27
推荐指数
4
解决办法
1万
查看次数

更改inputAccessoryView问题的高度

当我更改inputAccessoryViewiOS 8中的高度时,inputAccessoryView不会转到右侧原点,而是覆盖键盘.

在此输入图像描述

以下是一些代码段:

在表视图控制器中

- (UIView *)inputAccessoryView {
    if (!_commentInputView) {
        _commentInputView = [[CommentInputView alloc] initWithFrame:CGRectMake(0, 0, [self width], 41)];
        [_commentInputView setPlaceholder:NSLocalizedString(@"Comment", nil) andButtonTitle:NSLocalizedString(@"Send", nil)];
        [_commentInputView setBackgroundColor:[UIColor whiteColor]];
        _commentInputView.hidden = YES;
        _commentInputView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
    }

    return _commentInputView;
}
Run Code Online (Sandbox Code Playgroud)

在CommentInputView中

#when the textview change height
- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height {
    if (height > _textView_height) {
        [self setHeight:(CGRectGetHeight(self.frame) + height - _textView_height)];
        [self reloadInputViews];
    }
}
Run Code Online (Sandbox Code Playgroud)

来自ios-helpers的 UIView类别

- (void)setHeight: (CGFloat)heigth {
    CGRect frame = self.frame;
    frame.size.height …
Run Code Online (Sandbox Code Playgroud)

ios inputaccessoryview ios8

17
推荐指数
2
解决办法
9198
查看次数

标签 统计

inputaccessoryview ×2

ios ×2

ios8 ×2

objective-c ×1