相关疑难解决方法(0)

如何知道何时将文本粘贴到UITextView中

将一块文本粘贴到UITextView时会触发什么事件?我需要在粘贴文本时修改textView的框架.

谢谢阅读.

xcode uitextview

16
推荐指数
7
解决办法
2万
查看次数

如何检查剪贴板上是否有内容

如何检查剪贴板上是否有内容?

如果剪贴板上有内容,则执行某个操作,如果没有,则执行另一个操作(如示例代码所示)

if (if in the clipboard, that is, then open the VC) {
        let modalViewController = self.storyboard?.instantiateViewController(withIdentifier: "Clipboard") as? ClipboardViewController
        modalViewController?.modalPresentationStyle = .overCurrentContext
        self.present(modalViewController!, animated: true, completion: nil)
} else (if the clipboard is empty then) {
        let alert = UIAlertController(title: "Clipboard is Empty", message: "It's recommended you bring your towel before continuing.", preferredStyle: .alert)

        alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: nil))
        alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil))

        self.present(alert, animated: true)
}
Run Code Online (Sandbox Code Playgroud)

clipboard ios swift

5
推荐指数
2
解决办法
3306
查看次数

标签 统计

clipboard ×1

ios ×1

swift ×1

uitextview ×1

xcode ×1