Search code examples
iphone-5ios7xcode5

UIAlertViewStyleSecureTextInput not working with ios 7


i have a issues to use a uialertView with a TextFiled in ios 7.

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];

but in new SDK of ios 7 Creasing and Cresh Can-sol like

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) 

if any one develop with ios 7 and know how to solve this problem then help .

.....

if alert.alertViewStyle = UIAlertViewStyleSecureTextInput;

my xcode Version 5.0 (5A11386k)

is not working with ios 7 then we use old strategy like we do for ios 5 ?

thanks .


Solution

  • The problem is on your HomeViewController. You have a

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

    This means you are trying to access an index that doesn't exists, I think on line 246