簡體   English   中英

更改方向錯誤IOS

[英]Changing orientation error IOS

嘗試更改方向時出現異常。 我似乎無法解決這個例外。 異常本身無濟於事,因為它一直指向允許我更改方向的代碼行,但是描述說嘗試從objects [0]插入nil,這表明在插入數組時出錯。 我在調試中嘗試了異常斷點和工具。 還打開了nszombie。 還確保在添加到數組或初始化數組之前檢查nil是否為nil。 所以我不再知道可能是什么問題,或者我將采取何種行動來解決此問題。 至於數組,我有一個名為arraydata的數組,該數組在viewdidload初始化。 當它為nil和/或count <1時。我調用填充該數組的af響應,以確保它具有內容。 日志也很好,它總是返回count> 0。 無論如何,我希望這里可以提供幫助的是例外。 提前致謝

2015-10-02 21:40:18.801 NCR Video[4755:94868] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0   CoreFoundation                      0x00000001126bdc65 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000112356bb7 objc_exception_throw + 45
2   CoreFoundation                      0x0000000112582478 -[__NSPlaceholderArray initWithObjects:count:] + 360
3   CoreFoundation                      0x00000001125e1384 +[NSArray arrayWithObjects:count:] + 52
4   UIKit                               0x000000010ff6b83f _UIViewTopDownSubtreeTraversal + 127
5   UIKit                               0x000000011004aa57 -[UIViewController _replaceViewControllerInPresentationHierarchy:] + 120
6   UIKit                               0x000000011004a9a5 -[UIViewController _adaptedPresentationControllerForTraitCollection:withTransitionCoordinator:] + 430
7   UIKit                               0x000000011001f823 -[UIPresentationController _sharedParent:willTransitionToTraitCollection:withTransitionCoordinator:] + 273
8   UIKit                               0x000000011001f6f2 -[UIPresentationController _window:willTransitionToTraitCollection:withTransitionCoordinator:] + 37
9   UIKit                               0x000000011003dcaa -[UIViewController _window:willTransitionToTraitCollection:withTransitionCoordinator:] + 337
10  UIKit                               0x000000011003dcaa -[UIViewController _window:willTransitionToTraitCollection:withTransitionCoordinator:] + 337
11  UIKit                               0x000000011003dcaa -[UIViewController _window:willTransitionToTraitCollection:withTransitionCoordinator:] + 337
12  UIKit                               0x000000010ff5f891 -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 321
13  UIKit                               0x000000010ff61cb7 -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 1741
14  UIKit                               0x000000010ff625fa -[UIWindow _setRotatableClient:toOrientation:applyTransformToWindow:updateStatusBar:duration:force:isRotating:] + 559
15  UIKit                               0x000000010ff6156e -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 116
16  UIKit                               0x000000010ff614f4 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 36
17  UIKit                               0x000000010ff613a1 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 122
18  UIKit                               0x000000010ff6043e __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 98
19  UIKit                               0x000000010ff6038e -[UIWindow _updateToInterfaceOrientation:duration:force:] + 391
20  UIKit                               0x000000010ff607d0 -[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 316
21  CoreFoundation                      0x000000011268d54c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
22  CoreFoundation                      0x000000011258ba04 _CFXNotificationPost + 2484
23  Foundation                          0x000000010fa4e968 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
24  UIKit                               0x0000000110187e59 -[UIDevice setOrientation:animated:] + 282
25  Foundation                          0x000000010fa8db53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
26  NCR Video                           0x000000010e44ea0b -[PlayRealStream toFullScreen] + 779
27  NCR Video                           0x000000010e454611 -[PlayRealStream fullscr:] + 177
28  UIKit                               0x000000010ff0fda2 -[UIApplication sendAction:to:from:forEvent:] + 75
29  UIKit                               0x000000011002154a -[UIControl _sendActionsForEvents:withEvent:] + 467
30  UIKit                               0x0000000110020919 -[UIControl touchesEnded:withEvent:] + 522
31  UIKit                               0x000000010ff5c998 -[UIWindow _sendTouchesForEvent:] + 735
32  UIKit                               0x000000010ff5d2c2 -[UIWindow sendEvent:] + 682
33  UIKit                               0x000000010ff23581 -[UIApplication sendEvent:] + 246
34  UIKit                               0x000000010ff30d1c _UIApplicationHandleEventFromQueueEvent + 18265
35  UIKit                               0x000000010ff0b5dc _UIApplicationHandleEventQueue + 2066
36  CoreFoundation                      0x00000001125f1431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
37  CoreFoundation                      0x00000001125e72fd __CFRunLoopDoSources0 + 269
38  CoreFoundation                      0x00000001125e6934 __CFRunLoopRun + 868
39  CoreFoundation                      0x00000001125e6366 CFRunLoopRunSpecific + 470
40  GraphicsServices                    0x0000000114fd1a3e GSEventRunModal + 161
41  UIKit                               0x000000010ff0e900 UIApplicationMain + 1282
42  NCR Video                           0x000000010e42549f main + 111
43  libdyld.dylib                       0x00000001138bb145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb) 

在viewDidLoad初始化數組

self.arrayData = [[NSMutableArray alloc]init];

在初始化方法

if(StreamList!=nil && StreamList.count > 0)
self.arrayData = [NSMutableArray arraywithArray:StreamList];

其中StreamList是包含對象的nsarray

好的,我為您找到了解決方案。 只需完全按照以下方式實現此方法即可:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM