在iOS 16.2上水平布局2个文本字段时,应用程序崩溃

uqjltbpv  于 2023-02-01  发布在  iOS
关注(0)|答案(1)|浏览(278)

我得到了iOS模拟器上的应用程序崩溃16.2时,布局2文本字段水平.
在iOS模拟器16.2上逐步重现:
环境:

  • xcode 14.2

  • iOS 16.2操作系统

  • 模拟器

  • 第1步:将2个文本字段(UITextField)合并到一个水平堆栈视图中,并带有前导、尾随、顶部和底部约束。

  • 第2步:为2个文本字段设置长文本(在文本字段末尾显示三个点)

  • 步骤3:点击第一个文本字段

  • 步骤4:点击第二个文本字段

    • 结果:应用程序在步骤4崩溃**

错误信息:

2023-01-30 14:16:57.647873+0700 iOS16dot2TextFieldBug[18988:1850296] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff8004288ab __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80004dba3 objc_exception_throw + 48
    2   CoreFoundation                      0x00007ff800428789 -[NSException initWithCoder:] + 0
    3   QuartzCore                          0x00007ff80897d05e -[CALayer setPosition:] + 388
    4   UIKitCore                           0x000000010a2d90f4 -[UIView setCenter:] + 253
    5   UIKitCore                           0x0000000109105c2a -[_UIEditMenuPresentation _displayMenu:reason:] + 1959
    6   UIKitCore                           0x0000000109105387 -[_UIEditMenuPresentation displayMenu:configuration:] + 81
    7   UIKitCore                           0x000000010a29772a __58-[UIEditMenuInteraction presentEditMenuWithConfiguration:]_block_invoke + 207
    8   UIKitCore                           0x000000010a299222 __80-[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:]_block_invoke + 87
    9   UIKitCore                           0x000000010a0085cb __133-[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:]_block_invoke + 208
    10  UIKitCore                           0x000000010a008732 -[_UIContextMenuInteractionBasedTextContextInteraction _querySelectionCommandsForConfiguration:suggestedActions:completionHandler:] + 325
    11  UIKitCore                           0x000000010a0084da -[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:] + 126
    12  UIKitCore                           0x000000010a29918f -[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:] + 296
    13  UIKitCore                           0x000000010a297485 -[UIEditMenuInteraction presentEditMenuWithConfiguration:] + 240
    14  UIKitCore                           0x000000010a008d6d -[_UIContextMenuInteractionBasedTextContextInteraction presentSelectionCommandsWithConfiguration:] + 94
    15  UIKitCore                           0x000000010a05cb6f -[UITextSelectionView _presentEditMenuWithPreferredDirection:replacements:] + 103
    16  UIKitCore                           0x000000010a05c792 -[UITextSelectionView _showCommandsWithReplacements:isForContextMenu:forDictation:arrowDirection:] + 1487
    17  UIKitCore                           0x000000010a05c157 __77-[UITextSelectionView _showCommandsWithReplacements:forDictation:afterDelay:]_block_invoke + 262
    18  libdispatch.dylib                   0x000000010246bf5b _dispatch_client_callout + 8
    19  libdispatch.dylib                   0x000000010246f164 _dispatch_continuation_pop + 836
    20  libdispatch.dylib                   0x0000000102486d2e _dispatch_source_invoke + 2198
    21  libdispatch.dylib                   0x000000010247cbc7 _dispatch_main_queue_drain + 1065
    22  libdispatch.dylib                   0x000000010247c790 _dispatch_main_queue_callback_4CF + 31
    23  CoreFoundation                      0x00007ff800387b1f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    24  CoreFoundation                      0x00007ff800382436 __CFRunLoopRun + 2482
    25  CoreFoundation                      0x00007ff8003816a7 CFRunLoopRunSpecific + 560
    26  GraphicsServices                    0x00007ff809cb128a GSEventRunModal + 139
    27  UIKitCore                           0x0000000109ccbad3 -[UIApplication _run] + 994
    28  UIKitCore                           0x0000000109cd09ef UIApplicationMain + 123
    29  libswiftUIKit.dylib                 0x0000000102a18c72 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
    30  iOS16dot2TextFieldBug               0x000000010223c908 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
    31  iOS16dot2TextFieldBug               0x000000010223c897 $s21iOS16dot2TextFieldBug11AppDelegateC5$mainyyFZ + 39
    32  iOS16dot2TextFieldBug               0x000000010223c988 main + 24
    33  dyld                                0x00000001025912bf start_sim + 10
    34  ???                                 0x0000000102375310 0x0 + 4332147472
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 (BA2F723B-EEE6-48D0-89DD-9DAEC9E9A11E) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14

我刚在iOS模拟器16. 2上拿到这个问题,在低于iOS 16. 2的上一切正常。
充满了代码here
我不知道这是否是iOS 16.2的问题。
你们看到这个问题了吗?有能力的话帮我解决一下吧。
谢谢你。

fbcarpbf

fbcarpbf1#

这显然是一个错误
一种解决方法是将其添加到viewDidLoad()中(或在Storyboard中设置):

[emailTextField, websiteTextField].forEach {
        if let tf = $0 {
            tf.autocorrectionType = .no
            tf.spellCheckingType = .no
        }
    }

您的示例正在查找“email”和“website”条目,因此您可能并不需要这些条目。

相关问题