菜鸟教程小白 发表于 2022-12-13 10:15:44

ios - UITextView 滚动到底部,裁剪一半字符


                                            <p><p>我的应用程序是消息应用程序,并使用 <code>UITextView</code> 输入单词,以便它可以换行。 <code>UITextView</code> 机制是当 <code>UITextView 的</code> 高度增长到足以停止并自动滚动。在 <code>main.storyboard</code> 中,我取消选中滚动启用。因此,我使用 <code>setContentOffset</code>(如下所示)来实现机制。</p>

<pre><code>- (void)viewDidLoad {
    ;
    self.view.backgroundColor = ;
    [ addObserver:self selector:@selector(textDidChange:) name:UITextViewTextDidChangeNotification object:nil];
}

-(void)textDidChange:(NSNotification *)note
{
    CGSize contentSizeInTextView = ;
    if (contentSizeInTextView.height &gt; _textView.frame.size.height) {
    CGPoint offset = CGPointMake(0, contentSizeInTextView.height - _textView.frame.size.height);
    ;
    }
}
</code></pre>

<p>但是当我运行代码时,它会裁剪一半的单词,因为 stackoverflow 的声誉我无法发布图像。</p>

<p>你能告诉我我做错了什么吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以使用许多 Controller ,<a href="https://github.com/slackhq/SlackTextViewController" rel="noreferrer noopener nofollow">SlackTextViewController</a>是不错的选择。<br/></p>

<p>但你也可以使用其他的,其中一些是...<br/>
<a href="https://github.com/slackhq/SlackTextViewController" rel="noreferrer noopener nofollow">1. SlackTextViewController</a> <br/>
<a href="https://github.com/rcmcastro/whatsapp-ios" rel="noreferrer noopener nofollow">2. whatsapp-ios</a> <br/>
<a href="https://github.com/datwelk/RDRStickyKeyboardView" rel="noreferrer noopener nofollow">3. RDRStickyKeyboardView</a> <br/>
<a href="https://github.com/dc7batman/AMMessageComposer" rel="noreferrer noopener nofollow">4. AMMessageComposer</a> <br/>
<a href="https://github.com/tristanhimmelman/THSpringyCollectionView" rel="noreferrer noopener nofollow">5. THSpringyCollectionView</a> <br/>
<a href="https://github.com/acani/Chats" rel="noreferrer noopener nofollow">6. Chats</a> <br/>
<a href="https://github.com/samsoffes/ssmessagesviewcontroller" rel="noreferrer noopener nofollow">7. ssmessagesviewcontroller</a> <br/></p>

<p>我以后会在里面添加更多的控制。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - UITextView 滚动到底部,裁剪一半字符,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32323131/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32323131/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - UITextView 滚动到底部,裁剪一半字符