- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我创建了一个带有可检测链接的 UITextView,但是我无法使用 UITextView 委托(delegate)函数“shouldinteractwithURL”。
我收到一条警告,指出该实例方法几乎与另一个实例方法匹配。我查看了委托(delegate)函数,'shouldinteractwithURL' 函数已针对 ios 10.0 进行了更新,但是我想使用与 ios 9 兼容的函数版本。但是,即使我使用新版本并设置部署目标到 ios 10,我得到了相同的警告并且函数仍然没有被调用(我已经正确发送了 textview 委托(delegate))。
Xcode 建议的解决方案是将函数设为私有(private)或添加@nonobjc。这些都不起作用,因此单击链接时没有任何反应。
有没有其他人遇到过这个问题,或者这是 Xcode 8.0 的问题?
最佳答案
通过添加@availability
属性,编译时不会出错:
//For iOS 7...9
@available(iOS, deprecated: 10.0)
func textView(_ textView: UITextView, shouldInteractWith url: URL, in characterRange: NSRange) -> Bool {
var result = false
//...
return result
}
//For iOS 10
@available(iOS 10.0, *)
func textView(_ textView: UITextView, shouldInteractWith url: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
var result = false
//...
return result
}
关于xcode - UITextViewDelegate 函数应该在 Xcode 8.0 中与 URL 交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38170591/
我的 View Controller 变得越来越复杂,所以我决定将一些控件组合在一起并子类化一个 uiview。在我的 View Controller 中,我正在抓取 View : @property
我遇到了一个问题,即在键盘上按住删除键时,iOS 会向我的 UITextViewDelegate 提供不正确的信息。 当用户按住 iPad 上的 UITextView 上的删除键时,UITextVie
正在尝试为 UITextViewDelegate 和 UITextFieldDelegate 创建自定义委托(delegate)类。当我将这些类设置为它们自己的委托(delegate)时,或将另一个
我正在使用 swift 3,我有一个类如下: class Assistor : NSObject , UITextViewDelegate { private override init() { }
我有一个 UITableViewCell,我有一个评论 UITextView 来写评论。在写下评论时,我检查了 #hashtags 和 @mentions 以检查它们在应用程序服务器端的可用性并将它们
我正在尝试创建一个类,其唯一目的是实现 UITextViewDelegate,但由于某种原因,从未调用方法 shouldChangeTextInRange,这是我的代码: public class T
我正在尝试使用 UItextfields 委托(delegate)从 UITextField 动态更新 UITableViewCell,但它总是落后一个字符。 因此,如果我在 UITextView 中
当使用外部键盘时,我的 UITextView 会在我按下 Backspace 键(“向后删除”)时触发 shouldChangeTextInRange 消息,但如果我按下 Delete ( "forw
我一定是做错了什么,我的 UITextViewDelegate 实现方法没有触发。我有一个 UITextView,它是 UITableCellView 的 subview ,并且没有调用委托(dele
我正在尝试覆盖 textView shouldInteractWithURL 方法来处理可点击链接。所以我创建了一个继承自 UITextView 和 UITextViewDelegate 的子类,调用
我创建了一个带有可检测链接的 UITextView,但是我无法使用 UITextView 委托(delegate)函数“shouldinteractwithURL”。 我收到一条警告,指出该实例方法几
如何将 UITextView 的“委托(delegate)”导出连接到实现 UITextViewDelegate 协议(protocol)的类? 我似乎找不到例子in the docs 奇怪的是 UI
我是一名优秀的程序员,十分优秀!