簡體   English   中英

長按手勢問題

[英]long press gesture issue

我在應用程序中按了很長的手勢,並且在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];

現在,跟蹤數據的格式要好得多。 現在,我看到它正在loadFromNib上發生,即使用戶長按也是如此。 而且這尤其有意義,如果筆尖是從另一個項目復制過來的。

請查看您是否在筆尖中找到手勢識別器。 如果在那兒,請檢查連接檢查器。 它可能具有一些無效的引用,可能引用了另一個項目中的符號。 (您可能會在一個或多個連接附近看到一個小“!”)。

如果找到了,那么問題就解決了。 刪除它,然后使用您在代碼中設置的GR。 (或在筆尖中重新配置指針,並在viewDidLoad中注釋掉代碼:)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM