0

在我的应用程序中,我使用 UICollectionView 显示包含图像和文本的自定义单元格的网格视图。为了支持所有屏幕尺寸,我重写了 IUICollectionViewDelegateFlowLayout 委托的 GetSizeForItem 方法。从 iOS 8.1 到 9.2(在模拟器和设备上测试),一切都很好。对于 iOS 9.3 模拟器网格视图正确呈现。但是,一旦我旋转屏幕,它就会崩溃并出现以下错误:

抛出 Objective-C 异常。名称:NSInvalidArgumentException 原因:-[NSNull 长度]:无法识别的选择器发送到实例 0x9065398 本机堆栈跟踪:0 CoreFoundation
0x08e38494异常预处理 + 180 1 libobjc.A.dylib
0x091abe02 objc_exception_throw + 50 2 CoreFoundation
0x08e42253 -[NSorObject(NSObject) doesNotRecognize) 275 3
CoreFoundation 0x08d7789d ___forwarding_
+ 1037 4 CoreFoundation 0x08d7746e _CF_forwarding_prep_0 + 14 5 CoreFoundation 0x08cf0cdb CFStringCompareWithOptionsAndLocale + 203 6 Foundation
0x00da5770 -[NSString compare:options:range:locale:] + 175 7
Foundation 0x00da56b9 -[NSString compare:options:range:] + 72 8 Foundation
0x00dab7f2 -[NSString caseInsensitiveCompare:] + 81 9 UIKit
0x0156e021 -[UIPhysicalKeyboardEvent _matchesKeyCommand:] + 357 10 UIKit 0x0147035e -[UIResponder _keyCommandForEvent:target:] + UIKit 0x01470531 -[UIResponder _keyCommandForEvent:target:] + 913 12 UIKit 0x0147019b -[UIResponder _keyCommandForEvent:] + 48 13 UIKit
0x0123e287 -[UIApplication handleKeyHIDEvent:] + 380 14 UIKit
0x0121234d _UIApplicationHandleEventQueue + 6743 15 CoreFoundation
0x08d4ae5f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15 16 CoreFoundation 0x08d40aeb __CFRunLoopDoSources0 + 523 17 CoreFoundation 0x08d3ff08 __CFRunLoopRun + 1032 18 CoreFoundation
0x08d3f846 CFRunLoopRunSpecific + 470 19 CoreFoundation
0x08d3f65b CFRunLoopRunInMode + 123 20 GraphicsServices
0x09b3f664 GSEventRunModal + 192 21 GraphicsServices
0x09b3f4a1 GSEventRun + 104 22 UIKit
0x01218eb9 UIApplicationMain + 160 23 ???
0x18c98020 0x0 + 415858720 24 ???
0x18c97e18 0x0 + 415858200 25 ???
0x18c95f98 0x0 + 415850392 26 ???
0x18c95cd4 0x0 + 415849684 27 ???
0x18c95e60 0x0 + 415850080 28 libmonosgen-2.0.dylib
0x088cee81 mono_jit_runtime_invoke + 705 29 libmonosgen-2.0.dylib
0x08a7e0af mono_runtime_invoke + 127 30 libmonosgen-2.0.dylib
0x08a82f71 mono_runtime_exec_main + 401 31 libmonosgen-2.0.dylib
0x08a82d35 mono_runtime_run_main + 629 32 libmonosgen-2.0.dylib
0x0893ac8d mono_jit_exec + 93 33 TutorMeNot.iOS
0x001ff440 xamarin_main + 2384 34 TutorMeNot.iOS
0x001da5a1 主要 + 113 35 libdyld.dylib
0x0a62ca25 开始 + 1 36 ???
0x00000003 0x0 + 3

4

1 回答 1

0

该问题与代码无关。这是我的观察结果,解决了我的问题。

我正在使用 TabBarController。在其中一个选项卡中,我将 UICollectionView 与自定义单元格一起使用。当我在 iOS 9.3 模拟器上运行 App 时,它正确显示了我的集合视图。

旋转模拟器 使用键盘快捷键“Command+arrow”。一旦我按下命令,它就会崩溃。但是当我使用 Hardware -> Rotate options menu 旋转模拟器时,它工作正常。

我也在 iPod 设备(iOS V9.3.2)上测试了这个并且运行良好。出于测试目的,我使用 Objective-C 创建了示例 UICollectionView 应用程序。当我在 iOS 9.3 模拟器上构建并运行该示例时,它运行良好,屏幕旋转没有任何崩溃。

希望 Xamarin 团队会寻找这个问题。

于 2016-05-18T11:57:31.733 回答