2014-11-06 56 views
0

當我使用iOS8時,彈出窗口崩潰了應用程序。 這是我所編寫的代碼,它是在該方法,當用戶選擇的酥料餅:在iOS7中打開彈出窗口時iOS8崩潰的應用程序

- (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的早期版本或之前版本中運行良好。你能幫我嗎?

謝謝

+0

如何定義'selectionPopover'? (嘗試使它成爲'強'屬性並使用'self.selectionPopover'來引用它。) – 2014-11-06 13:02:14

+0

根據錯誤您正在訪問文本字段的長度。但是textfield不存在。 ' - [UITextField長度]:無法識別的選擇器發送到實例0x7f0d6520' – 2014-11-06 13:02:39

+0

@Philip:選擇彈出窗口是UIView控制器,UIPopoverController * selectionPopover; – 2014-11-06 13:06:18

回答

0

某處你得到一個文本字段的長度。該文本框不存在或者您以錯誤的方式獲取。正確的方法是[的TextField.text長度]代替[文本字段長度]

+0

這是唯一的2個地方我使用文本字段,我使用[的TextField.text長度] – 2014-11-06 13:21:08

+0

- (BOOL)textFieldShouldReturn:(*的UITextField)文本框 { [文本字段resignFirstResponder]; 返回YES; } – 2014-11-06 13:24:01

+0

只是爲了澄清: NSUInteger newLength = [長度的TextField.text] + [字符串長度] - range.length; – 2014-11-06 13:24:40

相關問題