2014-11-06 4 views
0

Попав сбой приложения, когда я работаю с iOS8. Это код, который я написал, и это в способе, когда пользователь выбирает поповер:Ошибка приложения в iOS8 при открытии popover wokring в iOS7

- (IBAction) onSelectingDefect:(id)sender 
    { 
     if ([description isFirstResponder]) { 
      [self hideKeyBoard]; 
      return; 
     } 

     UIButton *button = (UIButton*)(sender); 
     UIButton *doneSelectingStatusButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
     doneSelectingStatusButton.frame = CGRectMake(85, 223, 149, 32); 
     [doneSelectingStatusButton setTintColor:[UIColor blackColor]]; 
     [doneSelectingStatusButton setTitle:@"Done" forState:UIControlStateNormal]; 
     [doneSelectingStatusButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
     [doneSelectingStatusButton setBackgroundImage:[UIImage imageNamed:@"cancel_button02.png"] forState:UIControlStateNormal]; 
     [doneSelectingStatusButton addTarget:self action:@selector(onPickerSelection:) forControlEvents:UIControlEventTouchUpInside]; 
     UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)]; 
     pickerView.showsSelectionIndicator = YES; 
     pickerView.delegate = self; 
     pickerView.dataSource = self; 
     BOOL isNill = TRUE; 
     int i; 
     for(i=0; i<[tableData count]; i++) 
     { 
      if([selectedPickerText isEqualToString:[tableData objectAtIndex:i]]) 
      { 
       isNill = FALSE; 
       break; 
      } 
     } 
     if(isNill) 
     { 
      [pickerView selectRow:0 inComponent:0 animated:YES]; //Orig 
      //self.selectedPickerText = [tableData objectAtIndex:0]; 
      self.selectedPickerText = [tableData objectAtIndex:0]; 
     } 
     else 
      [pickerView selectRow:i inComponent:0 animated:YES];//Orig 

     UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 320, 255)]; 
     [containerView addSubview:doneSelectingStatusButton]; 
     [containerView addSubview:pickerView]; 

     UIViewController *pickerViewController = [[UIViewController alloc] init]; 
     CGRect myRect = button.frame; 
     myRect.origin.x += 10; 
     myRect.origin.y += 10; 

     selectionPopover = [[UIPopoverController alloc] initWithContentViewController:pickerViewController]; 
     ((AppDelegate*) [UIApplication sharedApplication].delegate).secondPopOver = selectionPopover; 
     selectionPopover.delegate =self; 
     selectionPopover.popoverContentSize = CGSizeMake(320, 255); 
     [selectionPopover presentPopoverFromRect:selectDefect.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //Error iOS8 
     pickerViewController.view = containerView; 

     [containerView release]; 
     [pickerView release]; 
     [pickerViewController release]; 

    } 

Это ошибка я адресности:

2014-11-04 20:01:30.740 Service360[447:5288] -[UITextField length]: unrecognized selector sent to instance 0x7f0d6520 
2014-11-04 20:01:30.743 Service360[447:5288] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField length]: unrecognized selector sent to instance 0x7f0d6520' 
*** First throw call stack: 
(
    0 CoreFoundation      0x0321f946 __exceptionPreprocess + 182 
    1 libobjc.A.dylib      0x02d01a97 objc_exception_throw + 44 
    2 CoreFoundation      0x032275c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277 
    3 CoreFoundation      0x031703e7 ___forwarding___ + 1047 
    4 CoreFoundation      0x0316ffae _CF_forwarding_prep_0 + 14 
    5 CoreFoundation      0x03108d26 CFStringAppend + 374 
    6 CoreFoundation      0x0310684a __CFStringAppendFormatCore + 11754 
    7 CoreFoundation      0x031fc5f5 _CFStringCreateWithFormatAndArgumentsAux2 + 245 
    8 Foundation       0x028b7697 -[NSPlaceholderString initWithFormat:locale:arguments:] + 159 
    9 Foundation       0x028baf42 +[NSString stringWithFormat:] + 89 
    10 UIKit        0x0183dd34 -[UIViewController _presentViewController:withAnimationController:completion:] + 2825 
    11 UIKit        0x018405d2 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 345 
    12 UIKit        0x01840424 -[UIViewController presentViewController:animated:completion:] + 224 
    13 UIKit        0x01db0791 -[UIPopoverController _presentShimmedPopoverFromRect:inView:permittedArrowDirections:animated:] + 217 
    14 UIKit        0x01db0991 -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:] + 355 
    15 Service360       0x00369b52 -[POVendorFeedbackViewController onSelectingDefect:] + 2770 
    16 libobjc.A.dylib      0x02d177cd -[NSObject performSelector:withObject:withObject:] + 84 
    17 UIKit        0x016da23d -[UIApplication sendAction:to:from:forEvent:] + 99 
    18 UIKit        0x016da1cf -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64 
    19 UIKit        0x0180de86 -[UIControl sendAction:to:forEvent:] + 69 
    20 UIKit        0x0180e2a3 -[UIControl _sendActionsForEvents:withEvent:] + 598 
    21 UIKit        0x0180d50d -[UIControl touchesEnded:withEvent:] + 660 
    22 UIKit        0x0172a60a -[UIWindow _sendTouchesForEvent:] + 874 
    23 UIKit        0x0172b0e5 -[UIWindow sendEvent:] + 791 
    24 UIKit        0x016f0549 -[UIApplication sendEvent:] + 242 
    25 Service360       0x00068f22 -[MyApplication sendEvent:] + 178 
    26 UIKit        0x0170037e _UIApplicationHandleEventFromQueueEvent + 20690 
    27 UIKit        0x016d4b19 _UIApplicationHandleEventQueue + 2206 
    28 CoreFoundation      0x031431df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    29 CoreFoundation      0x03138ced __CFRunLoopDoSources0 + 253 
    30 CoreFoundation      0x03138248 __CFRunLoopRun + 952 
    31 CoreFoundation      0x03137bcb CFRunLoopRunSpecific + 443 
    32 CoreFoundation      0x031379fb CFRunLoopRunInMode + 123 
    33 GraphicsServices     0x044b424f GSEventRunModal + 192 
    34 GraphicsServices     0x044b408c GSEventRun + 104 
    35 UIKit        0x016d88b6 UIApplicationMain + 1526 
    36 Service360       0x0006793f main + 159 
    37 libdyld.dylib      0x077a7ac9 start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

линия, которая является причиной приложение к аварийному завершению:

[selectionPopover presentPopoverFromRect:selectDefect.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //Error iOS8 

В чем может быть проблема, которая вызывает эту ошибку. Приложение отлично работает в предыдущих или предыдущих версиях iOS. Можете ли вы помочь мне?

Thanks

+0

Как определяется 'selectionPopover'? (Попробуйте сделать это свойство 'strong' и использовать' self.selectionPopover' для ссылки на него.) –

+0

по ошибке вы получаете доступ к длине текстового поля. но текстовое поле не существует. '- [UITextField length]: непризнанный селектор, отправленный в экземпляр 0x7f0d6520' –

+0

@Philip: Selection popover - UIView Controller, UIPopoverController * selectionPopover; –

ответ

0

Где-то вы получаете длину текстового поля. Текстовое поле не существует или вы ошибаетесь. Правильный способ: [textfield.text length] вместо [длина поля текста].

+0

Это единственные 2 места, где я использую TextField и я использую [длина textfield.text] –

+0

- (BOOL) textFieldShouldReturn: (UITextField *) TextField { [TextField resignFirstResponder]; возвращение ДА; } –

+0

Только уточнить: NSUInteger newLength = [текстField.text длина] + [длина строки] - range.length; –

Смежные вопросы