проблема с длинным нажатием - PullRequest
0 голосов
/ 24 марта 2012

У меня в приложении длинный жест нажатия, и он хорошо работает в 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];

1 Ответ

1 голос
/ 24 марта 2012

Эти данные трассировки теперь намного лучше отформатированы.Теперь я вижу, что это происходит на loadFromNib, даже когда пользователь выполняет долгое нажатие.И это имеет смысл, особенно если перо было скопировано из другого проекта.

Пожалуйста, посмотрите, можете ли вы найти распознаватель жестов в вашем перо.Если это так, проверьте инспектор соединений.Может иметь недопустимые ссылки, возможно, на символы в другом проекте.(Вы, вероятно, увидите небольшое «!» Возле одного или нескольких соединений).

Если вы обнаружите это, то проблема решена.Удалите его и используйте GR, который вы установили в коде.(или повторно настройте указатели в кончике и закомментируйте код в viewDidLoad:).

...