gpt4 book ai didi

iphone - 在iPhone中添加两个UITextView问题?

转载 作者:行者123 更新时间:2023-11-29 04:49:55 25 4
gpt4 key购买 nike

我通过这种方式在iphone中添加了两个textview。我有两个 UITextView A 和 B。我已经在 UITextView A 上添加了 UITextView B,如下所示,

[A addSubview:B]; 
[self.view addSubview:A];

当我开始在 TextView 中输入时,文本显示在两个 TextView 中都很好。当文本到达帧大小的最后一行时,它开始在 TextView B 中自动滚动,但 TextView A 不会自动滚动。可以添加 UITextView 的 UITextView subview 并访问两个 TextView 。谁能帮帮我吗。提前致谢。

最佳答案

您可以从

开始
- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text

委托(delegate)方法。在此方法中,您可以将字符串/文本设置为 B TextView ,如下所示:

- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if (textView.tag == 1001] // Text view A
{
[tempString appendString:string]; // The tempString is mutable string
textViewB.text = temp;
}

return TRUE;
}

希望它能给你一个想法。 (未经过完全测试的代码。)

关于iphone - 在iPhone中添加两个UITextView问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9003268/

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