更改方向错误IOS

时间:2015-10-02 13:55:47

标签: ios iphone exception xcode6

我在尝试改变方向时遇到异常。我似乎无法度过这个例外。异常本身没有帮助,因为它一直指向允许我改变方向的代码行,但描述说试图从对象[0]插入nil,这表示插入数组时出错。我在调试时尝试了异常断点和仪器。也有nszombie打开。还确保在添加到数组或初始化数组之前检查是否为nil。所以我不知道可能是什么问题或我将采取什么样的行动来解决这个问题。至于数组我有一个名为arraydata的数组,它在viewdidload初始化。当它为零和/或计数时< 1.我呼吁填充阵列的af响应,以确保它有内容。日志也很好,它返回计数&gt;总是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

1 个答案:

答案 0 :(得分:0)

好的,我已经找到了适合你的解决方案。只需实现这个方法:

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