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

标签 iphone ios uitextview subview

我通过这种方式在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/

相关文章:

flash - 如何在 iOs 的 Flash 应用程序中播放视频 (iPhone Packager)

ios - UITextView/UITextField 中的格式化文本/标签

ios - 多行自动调整大小的 UITextView

iphone - 如何用颜色填充形状

ios - Restkit — 如何映射具有可变键名的 json 对象

iphone - 多行 UIAlertView 消息崩溃

ios - 生成无法导出的私钥

iphone - 应用程序中的帮助菜单

ios - (Swift) 如何对Core Data进行模糊搜索?

ios - UITextView 链接不可点击 iOS 8