2013-01-05 2 views
0

나는 DialogViewController을로드하는 앱이 있습니다. 여기에는 여러 요소가 포함되어 있습니다. 요소 중 하나는 RootElement입니다. 이 RootElement는 EntryElement을 포함합니다.iOS (Monotouch) 앱이 ViewWillAppear에서 충돌 함

viewDidAppear에서 나는 EntryElement에서 되돌아 왔으며 입력 항목에 값이 있습니다. 즉 값을 추가했습니다. 해당 값을 내보기의 캡션으로 사용하고 싶습니다.

보기는 상위 제어기에서 생성됩니다

public TabBarController() 
    { 
     root = new RootElement("My Budget"); 
     root.UnevenRows = true; 

     tab1 = new TestController(root); 

     nav = new UINavigationController(tab1); 
     nav.Title = "Budget"; 

     var tabs = new UIViewController []{ 
      nav 
     }; 

     ViewControllers = tabs; 
     SelectedViewController = nav; 
    } 

그런 다음 컨트롤러에서 - 마법 그러나
public override void ViewWillAppear (bool animated) 
    { 
     base.ViewWillAppear (animated); 
     var caption = "Value.."; 

     if (BankElement != null && !String.IsNullOrWhiteSpace (BankElement.Value)){ 
      caption = BankElement.Value; 
     } 

     MyRoot = new RootElement ("Root"); 
     MyRoot.Caption = caption; 
     BankElement = new EntryElement("Enter", caption, ""); 

     MyRoot.Add (new Section("") {BankElement}); 
     rootelement = new RootElement("Root"); 
     rootelement.Add (new Section("") {MyRoot}); 

     Root = rootelement; 
    } 

일이 [한다], 때 viewDidAppear 실행 내가 할 수있는 스택 추적. 나는 매번 그것을 얻지 못한다. - 때때로.

스택 트레이스 :

at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff> 
    at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
    at BudgetPlanner.Application.Main (string[]) [0x00000] in /Users/Ashley/github/local/BudgetPlanner/BudgetPlanner/Main.cs:18 
    at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff> 

기본 스택 트레이스 :

0 BudgetPlanner      0x00095f7c mono_handle_native_sigsegv + 284 
1 BudgetPlanner      0x0000be98 mono_sigsegv_signal_handler + 248 
2 libsystem_c.dylib     0x908bd86b _sigtramp + 43 
3 ???         0xffffffff 0x0 + 4294967295 
4 UIKit        0x028014d0 -[UITextField canResignFirstResponder] + 33 
5 UIKit        0x0284761f -[UIResponder resignFirstResponder] + 82 
6 UIKit        0x02801b36 -[UITextField resignFirstResponder] + 141 
7 UIKit        0x0277f517 -[UIView(Hierarchy) _removeFirstResponderFromSubtree] + 209 
8 UIKit        0x0277f873 __UIViewWillBeRemovedFromSuperview + 77 
9 UIKit        0x0277f783 -[UIView(Hierarchy) removeFromSuperview] + 70 
10 UIKit        0x029b73fe -[UINavigationTransitionView _cleanupTransition] + 103 
11 UIKit        0x029b7698 -[UINavigationTransitionView _navigationTransitionDidStop] + 55 
12 UIKit        0x027773b6 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 237 
13 UIKit        0x02777554 -[UIViewAnimationState animationDidStop:finished:] + 68 
14 QuartzCore       0x04bc57d8 _ZN2CA5Layer23run_animation_callbacksEPv + 284 
15 libdispatch.dylib     0x04186014 _dispatch_client_callout + 14 
16 libdispatch.dylib     0x041767d5 _dispatch_main_queue_callback_4CF + 296 
17 CoreFoundation      0x012fcaf5 __CFRunLoopRun + 1925 
18 CoreFoundation      0x012fbf44 CFRunLoopRunSpecific + 276 
19 CoreFoundation      0x012fbe1b CFRunLoopRunInMode + 123 
20 GraphicsServices     0x04d237e3 GSEventRunModal + 88 
21 GraphicsServices     0x04d23668 GSEventRun + 104 
22 UIKit        0x0273965c UIApplicationMain + 1211 
23 ???         0x0b4ee83c 0x0 + 189720636 
24 ???         0x0b4eb0a0 0x0 + 189706400 
25 ???         0x0b4ea7f8 0x0 + 189704184 
26 ???         0x0b4ea903 0x0 + 189704451 
27 BudgetPlanner      0x00010252 mono_jit_runtime_invoke + 722 
28 BudgetPlanner      0x0017478e mono_runtime_invoke + 126 
29 BudgetPlanner      0x00178be4 mono_runtime_exec_main + 420 
30 BudgetPlanner      0x00178f55 mono_runtime_run_main + 725 
31 BudgetPlanner      0x0006ba65 mono_jit_exec + 149 
32 BudgetPlanner      0x0021f65d main + 2013 
33 BudgetPlanner      0x00003125 start + 53 

================================================================= 
Got a SIGSEGV while executing native code. This usually indicates 
a fatal error in the mono runtime or one of the native libraries 
used by your application. 
================================================================= 

이 컨트롤러의 훨씬 단순화 된 버전입니다 - 단지 루트 뷰가 표시되는로 - 훨씬 더 실제 컨트롤러가 데이터.

이 예외에 대한 아이디어가 있습니까? 정말로 나를 혼란스럽게하기 시작했다. (시뮬레이터에 Monotouch 6.0.8을 실행)

감사 애쉬는 ...

답변

1

나는이에게 자신을 해결했습니다.

내가 생각하는 문제는 새로 고침 할 때마다 다시로드 할 때 루트 요소를 바꾸는 것이 문제라고 생각합니다. 코드를 수정했습니다 :

public override void ViewWillAppear (bool animated) 
    { 
     base.ViewWillAppear (animated); 
     var caption = "Value.."; 

     if (BankElement != null && !String.IsNullOrWhiteSpace (BankElement.Value)) { 
      caption = BankElement.Value; 
     } 

     if (MyRoot == null) { 
      MyRoot = new RootElement ("Root"); 
      BankElement = new EntryElement("Enter", caption, ""); 
      MyRoot.Add (new Section("") {BankElement}); 
      rootelement = new RootElement("Root"); 
      rootelement.Add (new Section("") {MyRoot}); 

      Root = rootelement; 
     } 


     MyRoot.Caption = caption; 
    } 

이제 루트 요소 만 만들고 컨트롤러에 한 번 추가 한 다음 방금 업데이트합니다. 지금까지 좋은 것 같습니다!

관련 문제