【问题标题】:'NSInvalidArgumentException', reason: '-[__NSArrayI leftCapWidth]'NSInvalidArgumentException',原因:'-[__NSArrayI leftCapWidth]
【发布时间】:2010-11-22 11:46:28
【问题描述】:

我有三个继承自 UITableViewController 类的视图。第一个显示位置列表,第二个显示带有注释的地图,该注释表示在第一个视图中选择的行的位置,最后一个显示有关位置的信息(地址,图像,...)。有时当我将返回按钮按到第二个视图时,我会收到此错误消息。

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'

我不知道为什么会收到此消息。有人可以帮我吗?

感谢阅读。

【问题讨论】:

    标签: objective-c ios nsexception


    【解决方案1】:

    我敢打赌,这是一个内存管理问题。我认为您的应用会尝试访问之前发布的对象。

    启用 NSZombie 并查看这是否会更改错误消息:

    1. 双击可执行文件组中的可执行文件
    2. 打开第二个标签,arguments
    3. Variables to be set in the environment下添加一个名为NSZombieEnabled的变量,其值为YES,并通过勾选它前面的复选框来启用它。
    4. 再次运行您的程序
    5. ??
    6. 利润

    【讨论】:

    • 现在我收到此错误消息。 -[UIImage isKindOfClass:]:消息发送到已释放实例 0x6b751a0。是同样的错误信息吗?
    • 所以你正在(自动)在不应该释放的地方释放 UIImage。我会检查该版本的所有 viewWillDisappear、viewDidDisappear 方法。您是否尝试过分析仪来追踪该问题?使用 Build 菜单中的 Clean all targets,然后从同一菜单中运行 Build and analyze。如果您发现了该错误,请不要忘记删除 NSZombieEnabled 前面的勾号。
    • 非常感谢。我认为现在它工作正常。我不知道分析仪。我正在自动释放一个图像,该图像又被插入到一个也被自动释放的 UIImageView 中(自动释放的对象太多,我不知道这可能是一个错误)。这一切都是因为objective-c学得太快了。我欠你一美元。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多