當我在 UITextView 中粘貼一些復制的文本時,我的應用程式崩潰了。此崩潰僅在 iOS15 上發生
0 CoreFoundation 0x00007fff203feba4 __exceptionPreprocess 242
1 libobjc.A.dylib 0x00007fff201a1be7 objc_exception_throw 48
2 Foundation 0x00007fff20753aa2 _userInfoForFileAndLine 0
3 UIKitCore 0x00007fff254164a5 -[_UITextKitTextPosition compare:] 235
4 UIKitCore 0x00007fff254097b4 -[UITextInputController comparePosition:toPosition:] 85
5 UIKitCore 0x00007fff2542ac7d -[UITextView comparePosition:toPosition:] 85
6 UIKitCore 0x00007fff253d0251 -[UITextPasteController _clampRange:] 634
7 UIKitCore 0x00007fff253d09c4 __87-[UITextPasteController _performPasteOfAttributedString:toRange:forSession:completion:]_block_invoke 40
8 UIKitCore 0x00007fff253d0bcc __87-[UITextPasteController _performPasteOfAttributedString:toRange:forSession:completion:]_block_invoke.174 184
9 UIKitCore 0x00007fff25412629 -[UITextInputController _pasteAttributedString:toRange:completion:] 471
10 UIKitCore 0x00007fff253d092a -[UITextPasteController _performPasteOfAttributedString:toRange:forSession:completion:] 726
11 UIKitCore 0x00007fff253cfc07 __49-[UITextPasteController _executePasteForSession:]_block_invoke 299
12 libdispatch.dylib 0x00007fff2011265a _dispatch_call_block_and_release 12
13 libdispatch.dylib 0x00007fff2011383a _dispatch_client_callout 8
14 libdispatch.dylib 0x00007fff20120c88 _dispatch_main_queue_callback_4CF 1075
15 CoreFoundation 0x00007fff2036c84d __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 9
16 CoreFoundation 0x00007fff203670aa __CFRunLoopRun 2772
17 CoreFoundation 0x00007fff203660f3 CFRunLoopRunSpecific 567
18 GraphicsServices 0x00007fff2c995cd3 GSEventRunModal 139
19 UIKitCore 0x00007fff25059f42 -[UIApplication _run] 928
20 UIKitCore 0x00007fff2505eb5e UIApplicationMain 101
uj5u.com熱心網友回復:
使您的視圖控制器符合UITextPasteDelegate:
class viewController: UIViewController, UITextPasteDelegate { ...
并設定過去的delagete:
textView.pasteDelegate = self
然后實作textPasteConfigurationSupporting函式:
func textPasteConfigurationSupporting(
_ textPasteConfigurationSupporting: UITextPasteConfigurationSupporting,
performPasteOf attributedString: NSAttributedString,
to textRange: UITextRange)
-> UITextRange {
<#code#>
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/426061.html
標籤:IOS 迅速 目标-c uikit uitextview
