2010-11-22 34 views
3

我有三個繼承自UITableViewController類的視圖。第一個顯示位置列表,第二個顯示帶有註釋的地圖,該註釋代表在第一個視圖中選擇的行的位置,最後一個顯示關於位置(地址,圖像等)的信息。有時候,當我將後退按鈕推入第二個視圖時,我收到此錯誤消息。'NSInvalidArgumentException',原因:' - [__ NSArrayI leftCapWidth]

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI leftCapWidth]: unrecognized selector sent to instance 0x6b57110' 
*** Call stack at first throw: 
(
0 CoreFoundation      0x02576919 __exceptionPreprocess + 185 
1 libobjc.A.dylib      0x026c45de objc_exception_throw + 47 
2 CoreFoundation      0x0257842b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
3 CoreFoundation      0x024e8116 ___forwarding___ + 966 
4 CoreFoundation      0x024e7cd2 _CF_forwarding_prep_0 + 50 
5 UIKit        0x003935b9 -[UIImageView(UIImageViewInternal) _shouldDrawImage:] + 35 
6 UIKit        0x00392f3a -[UIImageView(UIImageViewInternal) _canDrawContent] + 411 
7 UIKit        0x00308f20 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 955 
8 UIKit        0x00308cfc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407 
9 UIKit        0x00308cfc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407 
10 UIKit        0x00308cfc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407 
11 UIKit        0x0031119a -[UIScrollView _didMoveFromWindow:toWindow:] + 71 
12 UIKit        0x00308cfc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407 
13 UIKit        0x00307b10 -[UIView(Hierarchy) _postMovedFromSuperview:] + 166 
14 UIKit        0x00300a34 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080 
15 UIKit        0x002fed87 -[UIView(Hierarchy) addSubview:] + 57 
16 UIKit        0x0050a829 -[UINavigationTransitionView transition:fromView:toView:] + 551 
17 UIKit        0x0050a28d -[UINavigationTransitionView transition:toView:] + 56 
18 UIKit        0x00381329 -[UINavigationController _startDeferredTransitionIfNeeded] + 266 
19 UIKit        0x00380fc7 -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:] + 386 
20 UIKit        0x00381141 -[UINavigationController popViewControllerAnimated:] + 57 
21 UIKit        0x003805b6 -[UINavigationController navigationBar:shouldPopItem:] + 148 
22 UIKit        0x00327143 -[UINavigationBar _popNavigationItemWithTransition:] + 116 
23 UIKit        0x0032def3 -[UINavigationBar _handleMouseUpAtPoint:] + 605 
24 UIKit        0x002f42ff -[UIWindow _sendTouchesForEvent:] + 567 
25 UIKit        0x002d61ec -[UIApplication sendEvent:] + 447 
26 UIKit        0x002daac4 _UIApplicationHandleEvent + 7495 
27 GraphicsServices     0x02ddcafa PurpleEventCallback + 1578 
28 CoreFoundation      0x02557dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
29 CoreFoundation      0x024b8737 __CFRunLoopDoSource1 + 215 
30 CoreFoundation      0x024b59c3 __CFRunLoopRun + 979 
31 CoreFoundation      0x024b5280 CFRunLoopRunSpecific + 208 
32 CoreFoundation      0x024b51a1 CFRunLoopRunInMode + 97 
33 GraphicsServices     0x02ddb2c8 GSEventRunModal + 217 
34 GraphicsServices     0x02ddb38d GSEventRun + 115 
35 UIKit        0x002deb58 UIApplicationMain + 1160 
36 TravelGuideTemplate     0x00002730 main + 102 
37 TravelGuideTemplate     0x000026c1 start + 53 
) 
terminate called after throwing an instance of 'NSException' 

我不明白爲什麼我收到這條消息。有人能幫助我嗎?

感謝您的閱讀。

回答

4

我敢打賭1 $這是一個內存管理問題。我認爲你的應用程序試圖訪問一個早些時候發佈的對象。

啓用NSZombie,看看這改變了錯誤消息:

  1. 雙擊可執行文件組
  2. 打開第二個選項卡中的可執行文件,arguments
  3. Variables to be set in the environment添加一個名爲NSZombieEnabled可變的,值爲YES,並通過勾選它前面的複選框來啓用它。
  4. 再次運行您的程序
  5. ??
  6. 獲利
+0

現在我收到此錯誤消息。 - [UIImage isKindOfClass:]:發送到解除分配的實例0x6b751a0的消息。是相同的錯誤信息? – 2010-11-22 12:06:14

+0

所以你(自動)釋放一個UIImage的地方不應該被釋放。我會檢查該版本的所有viewWillDisappear,viewDidDisappear方法。你有沒有試過分析器來追蹤這個問題?使用Build菜單中的Clean all targets,然後在同一菜單中運行Build and analyze。如果發現錯誤,不要忘記刪除NSZombieEnabled前面的勾號。 – 2010-11-22 12:11:24

+0

非常感謝。我認爲現在它工作正常。我不知道分析儀。我正在autoreleasing一個圖像,這反過來被插入到也autoreleased UIImageView(太多autoreleased對象,我不知道這可能是一個錯誤)。所有這些發生學習太快objective-c。我欠你一美元。 – 2010-11-22 12:48:23

相關問題