gpt4 book ai didi

ios - React Native 中带有 ScrollsToTop 的多行文本输入

转载 作者:行者123 更新时间:2023-11-29 11:30:02 26 4
gpt4 key购买 nike

当用户点击 iOS 上的状态栏时,我想在多行 TextInput 上执行“滚动到顶部”操作。 TextInput 在屏幕中具有最大比例,因此上下文相当直。

<TextInput multiline={true} scrollsToTop={true} />

但是,RCTMultilineTextInputViewbackedTextInputView 作为 subview ,并且 Prop 不会传递给 subview 。 (It's hardcoded 作为NO)

有什么办法可以通过这个 Prop 吗?或者,对于这种情况有什么更好的实现方式吗?

最佳答案

我通过类别添加了一个额外的属性scrollsToTop

// RCTMultilineTextInputView+ScrollsToTopAdditions.h

#import "RCTText/RCTMultilineTextInputViewManager.h"
#import <React/RCTViewManager.h>

NS_ASSUME_NONNULL_BEGIN

@interface RCTMultilineTextInputViewManager (ScrollsToTopAdditions)

@end

NS_ASSUME_NONNULL_END
// RCTMultilineTextInputViewManager+ScrollsToTopAdditions.m

#import "RCTMultilineTextInputViewManager+ScrollsToTopAdditions.h"

@implementation RCTMultilineTextInputViewManager (ScrollsToTopAdditions)
#if !TARGET_OS_TV
RCT_REMAP_VIEW_PROPERTY(scrollsToTop, backedTextInputView.scrollsToTop, BOOL)
#endif
@end

关于ios - React Native 中带有 ScrollsToTop 的多行文本输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54421417/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com