我正在为我的应用程序使用iphone 4s(iOS 7.0.3)的模拟器,我收到以下错误
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds [0 .. 1]'
*** First throw call stack:
(
0 CoreFoundation 0x003085e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027568b6 objc_exception_throw + 44
2 CoreFoundation 0x002a94e6 -[__NSArrayM objectAtIndex:] + 246
3 Requisitions 0x0015007a -[PasswordLoginController3 _adjustInputPos] + 61
4 Requisitions 0x0015042a -[PasswordLoginController3 keyboardWasShown:] + 312
5 Foundation 0x02428bf9 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
6 CoreFoundation 0x00364524 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
7 CoreFoundation 0x002bc00b _CFXNotificationPost + 2859
8 Foundation 0x02362951 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
9 UIKit 0x009ffb1b -[UIInputViewTransition postNotificationsForTransitionEnd] + 1054
10 UIKit 0x009f6138 __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1332 + 455
11 UIKit 0x006993c0 -[UINavigationControllerKeyboardAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 501
12 UIKit 0x009f5a7c -[UIPeripheralHost(UIKitInternal) executeTransition:] + 1258
13 UIKit 0x009f7c0e -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1029
14 UIKit 0x009f8019 -[UIPeripheralHost(UIKitInternal) setInputViews:animated:] + 72
15 UIKit 0x009f8063 -[UIPeripheralHost(UIKitInternal) setInputViews:] + 67
16 UIKit 0x009ef2fa -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1453
17 UIKit 0x006c969a -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 287
18 UIKit 0x006c8f8b -[UIResponder becomeFirstResponder] + 550
19 UIKit 0x005cc19b -[UIView(Hierarchy) becomeFirstResponder] + 114
20 UIKit 0x00c4ce43 -[UITextField becomeFirstResponder] + 51
21 UIKit 0x005cc1e8 -[UIView(Hierarchy) deferredBecomeFirstResponder] + 67
22 UIKit 0x005cc27c -[UIView(Hierarchy) _promoteSelfOrDescendantToFirstResponderIfNecessary] + 115
23 UIKit 0x005cc53e __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 224
24 UIKit 0x005cc388 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
25 UIKit 0x005d74c1 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
26 UIKit 0x005ca9b1 -[UIView(Hierarchy) addSubview:] + 56
27 UIKit 0x00563848 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 1927
28 UIKit 0x005d13ef +[UIView(Animation) performWithoutAnimation:] + 82
29 UIKit 0x00562c96 -[_UINavigationParallaxTransition animateTransition:] + 1155
30 UIKit 0x0069de4e -[UINavigationController _startCustomTransition:] + 3446
31 UIKit 0x006aa0c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
32 UIKit 0x006aacb9 -[UINavigationController __viewWillLayoutSubviews] + 57
33 UIKit 0x007e4181 -[UILayoutContainerView layoutSubviews] + 213
34 UIKit 0x005da267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
35 libobjc.A.dylib 0x0276881f -[NSObject performSelector:withObject:] + 70
36 QuartzCore 0x022182ea -[CALayer layoutSublayers] + 148
37 QuartzCore 0x0220c0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
38 QuartzCore 0x0220bf40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
39 QuartzCore 0x02173ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
40 QuartzCore 0x02174e71 _ZN2CA11Transaction6commitEv + 393
41 QuartzCore 0x02175544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
42 CoreFoundation 0x002d04ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
43 CoreFoundation 0x002d041f __CFRunLoopDoObservers + 399
44 CoreFoundation 0x002ae344 __CFRunLoopRun + 1076
45 CoreFoundation 0x002adac3 CFRunLoopRunSpecific + 467
46 CoreFoundation 0x002ad8db CFRunLoopRunInMode + 123
47 GraphicsServices 0x03ce39e2 GSEventRunModal + 192
48 GraphicsServices 0x03ce3809 GSEventRun + 104
49 UIKit 0x0056fd3b UIApplicationMain + 1225
50 Requisitions 0x000a712c main + 92
51 libdyld.dylib 0x03036701 start + 1
52 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我尝试了这个线程CRASH: *** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds [0 .. 9]并试图在某个断点进行调试,但没有用。我无法弄清问题在哪里发生。目标C不是我的强项,但仍然在解决这个问题。
方法_adjustInputPos
-(void) _adjustInputPos
{
UITextField *currentField = [inputFields objectAtIndex:currentInputIndex];
CGFloat currentInputHeight = currentField.frame.origin.y;
UIView* v = [self.formView viewWithTag:70];
if(v!=nil) {
currentInputHeight += v.frame.origin.y;
}
UIScrollView* sv = (UIScrollView*)self.view;
CGFloat offset = 0;
if (sv.contentOffset.y>=(currentInputHeight)) {
offset = (sv.frame.size.height-kbHeight)/1.5;
} else if((self.view.frame.size.height-kbHeight-currentInputHeight)<currentField.frame.size.height) {
offset = (sv.frame.size.height-kbHeight)/1.5;
} else {
return;
}
if(sv.contentOffset.y==offset) {
return;
}
CGPoint scrollPoint = CGPointMake(0.0, offset);
[sv setContentOffset:scrollPoint animated:YES];
}
方法keyBoardWasShown
- (void) keyboardWasShown:(NSNotification*)notf
{
if(isHidden) {
return;
}
NSDictionary *info = [notf userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
kbHeight = kbSize.height;
BOOL islandscape = [[ClientAuthenticator getInstance].actionHandler isLandscape];
if(!islandscape && [LSUtility isTablet]) {//ipad portrait,no need.
return;
}
if(islandscape ) {
kbHeight = kbSize.width;
}
if (is30Style) {
[self _adjustInputPos];
} else {
[self _adjustInputPos31];
}
UIScrollView *sv = (UIScrollView*)self.view;
CGSize size = CGSizeMake(sv.frame.size.width, sv.frame.size.height+kbHeight/1.5);
[sv setContentSize:size];
}
由于
答案 0 :(得分:5)
4294967295
为0xFFFFFFFF
十六进制,-1
为unsigned int
。
签入[PasswordLoginController3 _adjustInputPos]
- 它要求objectAtIndex
的值为-1
(超出范围)。
编辑,因为您添加了代码
UITextField *currentField = [inputFields objectAtIndex:currentInputIndex]
这看起来是错误来自的行。 currentInputIndex
的类型是什么,初始化/修改的位置是什么?