ios - 禁用双击弹出 UITextView
<p><p>双击<code>UITextView</code> 会弹出一个窗口。您可以在下图中看到它。我们如何禁用它? </p>
<p> <img src="/image/9ZnKX.png" alt="enter image description here"/> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试这个:</p>
<pre><code>txtView.selectable = NO;
</code></pre>
<p><strong>已编辑:</strong>
在你的 ViewController 中覆盖这个来处理,在你有 <code>UITextfield</code> 的地方使用这个代码。</p>
<pre><code>// Hide cut/copy/paste menu
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender {
UIMenuController *menuController = ;
if (menuController) {
.menuVisible = NO;
}
return NO;
}
</code></pre>
<p>对于 iOS 7 及更高版本,您需要这样做:</p>
<pre><code>- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
[ addOperationWithBlock:^{
[ setMenuVisible:NO animated:NO];
}];
return ;
}
</code></pre>
<p>希望它对你有用。</p></p>
<p style="font-size: 20px;">关于ios - 禁用双击弹出 UITextView,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/27566052/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/27566052/
</a>
</p>
页:
[1]