-1

我在 ios 7 中使用带有 TextFiled 的 uialertView 时遇到问题。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:nil delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
    [[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];
    [alert show];

但在 ios 7 Creasing 和 Cresh Can-sol 的新 SDK 中

AssertMacros: queueEntry,  file: /SourceCache/IOKitUser_Sim/IOKitUser-920.1.11/hid.subproj/IOHIDEventQueue.c, line: 512
2013-09-09 10:39:51.659 Food.de[912:a0b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
*** First throw call stack:
(
    0   CoreFoundation                      0x037a16f4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x02cc08b6 objc_exception_throw + 44
    2   CoreFoundation                      0x03742616 -[__NSArrayM objectAtIndex:] + 246
    3   Food.de                             0x0006583f -[HomeViewController addButtonToKeyboard] + 735
    4   Food.de                             0x00065e8e -[HomeViewController keyboardDidShow:] + 238
    5   Foundation                          0x02787089 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
    6   CoreFoundation                      0x037fd634 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
    7   CoreFoundation                      0x0375513b _CFXNotificationPost + 2859
    8   Foundation                          0x026c0de1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
    9   UIKit                               0x01cb8e97 -[UIInputViewTransition postNotificationsForTransitionEnd] + 1054
    10  UIKit                               0x01caf4b8 __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1329 + 455
    11  UIKit                               0x0188dc15 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 306
    12  UIKit                               0x018778bc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
    13  UIKit                               0x01877ba4 -[UIViewAnimationState animationDidStop:finished:] + 80
    14  QuartzCore                          0x00cb2e84 _ZN2CA5Layer23run_animation_callbacksEPv + 304
    15  libdispatch.dylib                   0x0316b4b0 _dispatch_client_callout + 14
    16  libdispatch.dylib                   0x03159766 _dispatch_main_queue_callback_4CF + 340
    17  CoreFoundation                      0x03806b6e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
    18  CoreFoundation                      0x037477eb __CFRunLoopRun + 1963
    19  CoreFoundation                      0x03746bf3 CFRunLoopRunSpecific + 467
    20  CoreFoundation                      0x03746a0b CFRunLoopRunInMode + 123
    21  GraphicsServices                    0x03e8fa27 GSEventRunModal + 192
    22  GraphicsServices                    0x03e8f84e GSEventRun + 104
    23  UIKit                               0x0182bf0b UIApplicationMain + 1225
    24  Food.de                             0x00006c1d main + 141
    25  Food.de                             0x00006b85 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

如果有人使用 ios 7 开发并知道如何解决此问题,请提供帮助。

......

如果 alert.alertViewStyle = UIAlertViewStyleSecureTextInput;

我的 xcode 版本 5.0 (5A11386k)

不使用 ios 7 那么我们使用旧策略,就像我们为 ios 5 做的那样?

谢谢 。

4

1 回答 1

1

问题出在你的HomeViewController. 你有一个

[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1] 

这意味着您正在尝试访问不存在的索引,我认为在线246

于 2013-09-09T07:50:21.497 回答