2012-03-23 69 views
0

我在我的应用程序中长按手势,它在ios 5.0中运行良好,但在ios 4.3中我有例外。下面是我在调试看到长按手势问题

[UILongPressGestureRecognizer initWithCoder:]: unrecognized selector sent to instance 0x5863360 
2012-03-23 23:39:30.384 Woods2[289:ef03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILongPressGestureRecognizer initWithCoder:]: unrecognized selector sent to instance 0x5863360' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x013415a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x01ce6313 objc_exception_throw + 44 
    2 CoreFoundation      0x013430bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x012b2966 ___forwarding___ + 966 
    4 CoreFoundation      0x012b2522 _CF_forwarding_prep_0 + 50 
    5 UIKit        0x005bb9fd UINibDecoderDecodeObjectForValue + 2592 
    6 UIKit        0x005bb2f5 UINibDecoderDecodeObjectForValue + 792 
    7 UIKit        0x005bc6ac -[UINibDecoder decodeObjectForKey:] + 398 
    8 UIKit        0x004d0c54 -[UINib instantiateWithOwner:options:] + 834 
    9 UIKit        0x004d2ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 
    10 UIKit        0x00388628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70 
    11 UIKit        0x00386134 -[UIViewController loadView] + 120 
    12 UIKit        0x0038600e -[UIViewController view] + 56 
    13 Woods2        0x00004f37 -[FirstViewController viewDidLoad] + 1671 
    14 UIKit        0x00386089 -[UIViewController view] + 179 
    15 UIKit        0x00398f54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120 
    16 UIKit        0x00397aaa -[UITabBarController transitionFromViewController:toViewController:] + 64 
    17 UIKit        0x003998a2 -[UITabBarController _setSelectedViewController:] + 263 
    18 UIKit        0x00399d5e -[UITabBarController viewWillLayoutSubviews] + 170 
    19 UIKit        0x004aa2e9 -[UILayoutContainerView layoutSubviews] + 226 
    20 QuartzCore       0x019faa5a -[CALayer layoutSublayers] + 181 
    21 QuartzCore       0x019fcddc CALayerLayoutIfNeeded + 220 
    22 QuartzCore       0x019a20b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310 
    23 QuartzCore       0x019a3294 _ZN2CA11Transaction6commitEv + 292 
    24 UIKit        0x002d89c9 -[UIApplication _reportAppLaunchFinished] + 39 
    25 UIKit        0x002d8e83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690 
    26 UIKit        0x002e3617 -[UIApplication handleEvent:withNewEvent:] + 1533 
    27 UIKit        0x002dbabf -[UIApplication sendEvent:] + 71 
    28 UIKit        0x002e0f2e _UIApplicationHandleEvent + 7576 
    29 GraphicsServices     0x015eb992 PurpleEventCallback + 1550 
    30 CoreFoundation      0x01322944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    31 CoreFoundation      0x01282cf7 __CFRunLoopDoSource1 + 215 
    32 CoreFoundation      0x0127ff83 __CFRunLoopRun + 979 
    33 CoreFoundation      0x0127f840 CFRunLoopRunSpecific + 208 
    34 CoreFoundation      0x0127f761 CFRunLoopRunInMode + 97 
    35 UIKit        0x002d87d2 -[UIApplication _run] + 623 
    36 UIKit        0x002e4c93 UIApplicationMain + 1160 
    37 Woods2        0x00001c2a main + 170 
    38 Woods2        0x00001b75 start + 53 
) 
terminate called throwing an exceptionkill 

非常感谢您的帮助

这里是viewDidLoad中

UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] 
             initWithTarget:self action:@selector(handleLongPress:)]; 
lpgr.minimumPressDuration = 0.2; //user needs to press for 2 seconds 
[mapView addGestureRecognizer:lpgr]; 
[lpgr release]; 
+0

您是否可以确认handleLongPress:是在创建它的视图控制器上实现的。 (initWithTarget:self引用的同一个类)? – danh 2012-03-23 21:50:25

+0

是的。我有mapView,这个mapView在viewdidload中有这个代码。所以我必须做什么?谢谢 – 2012-03-23 21:54:01

回答

1

的一些代码,跟踪数据要好得多格式化了。现在我看到它发生在loadFromNib上,即使用户长时间按下时也是如此。特别是如果笔尖是从另一个项目复制的,那么这很有意义。

请看看你是否能在你的笔尖找到一个手势识别器。如果它在那里,请检查连接检查器。它可能有一些无效的引用,可能是另一个项目中的符号。 (您可能会在一个或多个连接附近看到一点“!”)。

如果你发现,那么问题就解决了。将其删除,然后使用您在代码中设置的GR。 (或者重新配置笔尖中的指针并注释掉viewDidLoad中的代码:)。

+0

我现在有sigabrt在这里MapViewCntroller * map = [[MapViewCntroller alloc] init]; self.mapController = map; [self.view addSubview:self.mapController.view]; <----这是错误 [地图发布]; – 2012-03-24 07:49:58

+0

谢谢!非常 – 2012-03-24 08:13:51