2011-11-28 164 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

也許吧。確保在樂器中運行殭屍。 –