在iPad上解雇ModalViewControllerAnimated后崩溃

时间:2011-11-28 17:52:37

标签: objective-c ipad ios4 presentmodalviewcontroller

我的iPad应用程序遇到意外问题,我不确定自己是做错了还是这是正常的设备行为 -

  1. TableViewController - > didSelectRowAtIndexPath - > presentModalViewController
  2. modalView上的取消/保存操作 - > dismissModalViewControllerAnimated - >工作正常。
  3. 但是 -

    1. TableViewController - > didSelectRowAtIndexPath - > presentModalViewController
    2. 以90度更改设备方向(表示当前视图方向与父视图控制器方向不同
    3. 取消modalView上的操作 - > dismissModalViewControllerAnimated - > CRASH
    4. 我尝试在必要时使用setTranform修改模态视图 - 它确实会更改视图但不会更改self.interfaceOrientation值。

      我认为解决此问题的正确方法是将self.interfaceOrientation值修改为90度,但我真的不知道该怎么做 - 除非有更简单的解决方案。


      附上调试输出 - 也许它可以帮助......

      2011-11-29 11:09:35.981 myApp [65933:c203] -[UIDeviceWhiteColor count]: unrecognized selector sent to instance 0x7191bf0
      
      2011-11-29 11:09:35.985 myApp [65933:c203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDeviceWhiteColor count]: unrecognized selector sent to instance 0x7191bf0'
      
      *** Call stack at first throw:
      (
          0   CoreFoundation                      0x011dc5a9 __exceptionPreprocess + 185    
          1   libobjc.A.dylib                     0x015f7313 objc_exception_throw + 44   
          2   CoreFoundation                      0x011de0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
          3   CoreFoundation                      0x0114d966 ___forwarding___ + 966
          4   CoreFoundation                      0x0114d522 _CF_forwarding_prep_0 + 50
          5   myApp                               0x0000eac4 -[myTableViewController tableView:numberOfRowsInSection:] + 68
          6   UIKit                               0x005eb2b7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1834
          7   UIKit                               0x005ed8a4 -[UITableViewRowData rectForFooterInSection:] + 108
          8   UIKit                               0x005ed130 -[UITableViewRowData heightForTable] + 60
          9   UIKit                               0x004ada56 -[UITableView(_UITableViewPrivate) _updateContentSize] + 333
          10  UIKit                               0x004a50c0 -[UITableView _rectChangedWithNewSize:oldSize:] + 559
          11  UIKit                               0x004a3917 -[UITableView setFrame:] + 266
          12  UIKit                               0x00463a03 -[UIView(Geometry) resizeWithOldSuperviewSize:] + 385
          13  UIKit                               0x0046797b -[UIView(Geometry) resizeSubviewsWithOldSize:] + 273
          14  UIKit                               0x00463e94 -[UIView(Geometry) setFrame:] + 497
          15  UIKit                               0x004de475 -[UIViewControllerWrapperView setFrame:] + 79
          16  UIKit                               0x00463a03 -[UIView(Geometry) resizeWithOldSuperviewSize:] + 385
          17  UIKit                               0x0046797b -[UIView(Geometry) resizeSubviewsWithOldSize:] + 273
          18  UIKit                               0x00463e94 -[UIView(Geometry) setFrame:] + 497
          19  UIKit                               0x00463a03 -[UIView(Geometry) resizeWithOldSuperviewSize:] + 385
          20  UIKit                               0x0046797b -[UIView(Geometry) resizeSubviewsWithOldSize:] + 273
          21  UIKit                               0x004641c5 -[UIView(Geometry) setBounds:] + 623
          22  UIKit                               0x00601f51 -[UILayoutContainerView setBounds:] + 78
          23  UIKit                               0x004df4f7 -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] + 440
          24  UIKit                               0x0045655f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 4347
          25  UIKit                               0x006dd619 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1381
          26  UIKit                               0x004e3385 -[UIViewController _dismissModalViewControllerWithTransition:from:] + 2058
          27  UIKit                               0x004dfeb8 -[UIViewController dismissModalViewControllerWithTransition:] + 940
          28  myApp                               0x00014a04 -[myModalViewController cancelAdding:] + 132
          29  UIKit                               0x0042e4fd -[UIApplication sendAction:to:from:forEvent:] + 119
          30  UIKit                               0x004be799 -[UIControl sendAction:to:forEvent:] + 67
          31  UIKit                               0x004c0c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
          32  UIKit                               0x004bf7d8 -[UIControl touchesEnded:withEvent:] + 458
          33  UIKit                               0x00452ded -[UIWindow _sendTouchesForEvent:] + 567
          34  UIKit                               0x00433c37 -[UIApplication sendEvent:] + 447
          35  UIKit                               0x00438f2e _UIApplicationHandleEvent + 7576
          36  GraphicsServices                    0x02ce2992 PurpleEventCallback + 1550
          37  CoreFoundation                      0x011bd944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
          38  CoreFoundation                      0x0111dcf7 __CFRunLoopDoSource1 + 215
          39  CoreFoundation                      0x0111af83 __CFRunLoopRun + 979
          40  CoreFoundation                      0x0111a840 CFRunLoopRunSpecific + 208
          41  CoreFoundation                      0x0111a761 CFRunLoopRunInMode + 97
          42  GraphicsServices                    0x02ce11c4 GSEventRunModal + 217
          43  GraphicsServices                    0x02ce1289 GSEventRun + 115
          44  UIKit                               0x0043cc93 UIApplicationMain + 1160
          45  myApp                               0x00001c5a main + 170
          46  myApp                               0x00001ba5 start + 53
      )
      

      终止调用抛出异常当前语言:auto;目前的目标-c

      我的tableView numberOfRowsInSection:

      return [iphoneWordPlistUnsorted count];
      

      在.h文件中声明并在viewWillAppear方法上分配:

      [super viewWillAppear:animated];
      documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
      if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
      {
          path = [documentsDirectory stringByAppendingFormat:WORDS_PLIST_IPHONE];
          self.tableView.sectionHeaderHeight = 63;
          self.tableView.rowHeight = 80;
      }
      else
      {
          path = [documentsDirectory stringByAppendingFormat:WORDS_PLIST_IPAD];
          self.tableView.sectionHeaderHeight = 94;
          self.tableView.rowHeight = 120;
      }
      
      iphoneWordPlistUnsorted = [[NSMutableArray alloc] initWithContentsOfFile:path];
      iphoneWordsPlist = [iphoneWordPlistUnsorted sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
      
      [iphoneWordPlistUnsorted removeAllObjects];
      int i;
      for (i=0; i < [iphoneWordsPlist count]; i++) {
          [iphoneWordPlistUnsorted addObject:[iphoneWordsPlist objectAtIndex:i]];
      }
      
      [self.tableView reloadData];
      

      非常感谢,

      杜迪·

1 个答案:

答案 0 :(得分:0)

您的iphoneWordPlistUnsorted对象正在被取消分配,内存将被重新分配为其他内容。启用僵尸(在Xcode或在仪器中)运行将帮助您查明错误。