2011-11-28 166 views
0

我遇到意想不到的问题,我的iPad应用程序,我不知道如果我做错了或这是一个正常的设备行为dismissModalViewControllerAnimated -崩溃后的iPad

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

然而 -

  1. TableViewController - >didSelectRowAtIndexPath - >presentModalViewController
  2. 改变90度(装置设备方位,当前视图取向比父视图控制器取向
  3. 上的取消操作的不同modalView - >dismissModalViewControllerAnimated - > CRASH

我试图在必要时使用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 
) 

终止叫做抛出exceptionCurrent语言:汽车;目前Objective-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]; 

非常感谢,

杜迪·

+0

崩溃究竟是什么,发生了什么异常,什么是堆栈跟踪?根据崩溃情况,这可能与其他问题有关,如内存管理问题等。 –

+0

嗨, 这是我收到的错误: 2011-11-29 09:09:25.337 [65805:c203] - [UITextRenderingAttributes count]:无法识别的选择器发送到实例0x56339e0 2011-11-29 09:09:25.340 [65805:c203] ***由于未捕获的异常'NSInvalidArgumentException',原因:' - [UITextRenderingAttributes count]:无法识别选择器发送到实例0x56339e0' 它发生时,我点击“取消/保存”按钮,调用dismissModalViewControllerAnimated。 – Dudi

+0

再次 - 它不会发生这两个视图是在相同的方向 - 只有当他们有一个90/270度的差异。 感谢您的帮助 – Dudi

回答

0

您的iphoneWordPlistUnsorted对象正在交易并且内存正在被重新分配为别的东西。在启用僵尸的情况下运行(无论是在Xcode还是在乐器中)都可以帮助您查明错误。

+0

好吧,我看到了。我有 - [iphoneWordPlistUnsorted发布]; on viewwilldisappear方法 - 它可能是原因吗? – Dudi

+0

也许吧。确保在乐器中运行僵尸。 –