UINavigationController에 이상한 문제가 있습니다.UINavigationController setViewController를 사용할 때 응용 프로그램이 손상되는 경우
나는 세 가지 수준으로 데이터를 표시하는 App을 작성했습니다. (RootView : 데이터 I 선택, 두 번째보기 : 데이터 II 선택, 세 번째보기 : 데이터 표시). 이것은 큰 문제없이 작동합니다. PushMessage가 도착하면
이 문제가 나타납니다이 경우 내가 수동의 ViewController 스택을 만들려고 메소드 setViewControllers을 사용하고 있습니다 : 애니메이션 :
나는 세 개의 뷰 컨트롤러를 초기화하고 있습니다 (다음은 UINavigationController의 데이터, 제목 등)를 배열에 추가합니다. 이 배열은 위에서 언급 한 메서드 (setViewCOntrollers)로 전달되고 상위 ViewController의 뷰가 올바르게 표시됩니다. 그러나 사용자가 왼쪽 상단의 뒤로 버튼을 터치하면 앱이 다운됩니다. 이 버튼의 제목은 스택에있는 이전 ViewController의 제목이므로 스택이 정확하다고 보입니다. 이 오류는 푸시 알림 (setViewControllers 메서드를 호출하는 것을 의미)을받을 때 rootViewController의보기가 표시되는 경우에만 발생합니다.
내 코드 : 콘솔에 표시
EMASubstituteTeacherScheduleAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navController = [appDelegate viewController];
MainViewController *main = [[MainViewController alloc] initWithNibName: @"MainViewController" bundle: nil];
main.navigationItem.title = @"Test";
FormViewController *formSelect = [[FormViewController alloc] initWithNibName: @"FormViewController" bundle: nil];
formSelect.navigationItem.title = @"Test (Level 2)";
formSelect.substDate = [pushData objectForKey: @"date"];
SubstitutesViewController *substDisplay = [[SubstitutesViewController alloc] initWithNibName: @"SubstitutesViewController" bundle: nil];
substDisplay.navigationItem.title = @"Test (Top)";
substDisplay.substDate = [pushData objectForKey: @"date"];
substDisplay.substForm = [pushData objectForKey: @"form"];
NSArray *controllers = [[NSArray alloc] initWithObjects: main, formSelect, substDisplay, nil];
[navController setViewControllers: controllers animated:YES];
메시지 : "EXC_BAD_ACCESS" 프로그램 신호를 받았다.
호출 스택 : 사전에
'#0 0x3433886c in objc_msgSend'
'#1 0x3061a828 in -[UIApplication sendAction:to:from:forEvent:]
'#2 0x3061a7c8 in -[UIApplication sendAction:toTarget:fromSender:forEvent:]
'#3 0x3061a79a in -[UIControl sendAction:to:forEvent:]
'#4 0x3061a4ec in -[UIControl(Internal) _sendActionsForEvents:withEvent:]
'#5 0x3061ab3a in -[UIControl touchesEnded:withEvent:]
'#6 0x306194ec in -[UIWindow _sendTouchesForEvent:]
'#7 0x30618e66 in -[UIWindow sendEvent:]
'#8 0x30614b5a in -[UIApplication sendEvent:]
'#9 0x30614506 in _UIApplicationHandleEvent
'#10 0x3323a146 in PurpleEventCallback
'#11 0x3293daaa in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
'#12 0x3293f84e in __CFRunLoopDoSource1
'#13 0x3294062c in __CFRunLoopRun
'#14 0x328e98ea in CFRunLoopRunSpecific
'#15 0x328e97f2 in CFRunLoopRunInMode
'#16 0x332396ee in GSEventRunModal
'#17 0x3323979a in GSEventRun
'#18 0x305be2a6 in -[UIApplication _run]
'#19 0x305bce16 in UIApplicationMain
'#20 0x00002512 in main at main.m:14
감사합니다!