【问题标题】:Crash while long press on the tableview长按桌面视图时崩溃
【发布时间】:2011-12-22 01:56:48
【问题描述】:

我有一个包含自定义单元格的表格视图,一个单元格包含 uiimageview,uilabels 。当我按住并移动 uitableviewcell 时,有时我会因此日志而崩溃。如何消除此崩溃。我没有在我的应用程序中使用任何手势识别器,也没有使用任何点击或触摸检测。我只使用了 tableview 委托和数据源方法。 感谢您的帮助!

'-[CALayer _longPressGestureRecognized:]: unrecognized selector sent to instance 0x10d060'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x367cd64f __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x33a26c5d objc_exception_throw + 24
    2   CoreFoundation                      0x367d11bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
    3   CoreFoundation                      0x367d0649 ___forwarding___ + 508
    4   CoreFoundation                      0x36747180 _CF_forwarding_prep_0 + 48
    5   CoreFoundation                      0x3673af03 -[NSObject(NSObject) performSelector:withObject:] + 22
    6   UIKit                               0x35649f93 -[UIGestureRecognizer _updateGestureWithEvent:] + 562
    7   UIKit                               0x35649d57 -[UIGestureRecognizer _delayedUpdateGesture] + 22
    8   UIKit                               0x355b4afd _UIGestureRecognizerUpdateObserver + 436
    9   CoreFoundation                      0x367a4a35 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
    10  CoreFoundation                      0x367a6465 __CFRunLoopDoObservers + 412
    11  CoreFoundation                      0x367a775b __CFRunLoopRun + 854
    12  CoreFoundation                      0x36737ec3 CFRunLoopRunSpecific + 230
    13  CoreFoundation                      0x36737dcb CFRunLoopRunInMode + 58
    14  GraphicsServices                    0x35ef141f GSEventRunModal + 114
    15  GraphicsServices                    0x35ef14cb GSEventRun + 62
    16  UIKit                               0x355e1d69 -[UIApplication _run] + 404
    17  UIKit                               0x355df807 UIApplicationMain + 670
    18  MyAppName                          0x000029a7 main + 70
    19  MyAppName                          0x0000295c start + 40
)

【问题讨论】:

    标签: iphone uitableview calayer uigesturerecognizer


    【解决方案1】:

    您可以尝试通过在您的单元格中添加一个来拦截呼叫。这与在编辑模式下拖动和移动单元格的能力不冲突。我的桌子对两者都适用。

    在我的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    我在每个单元格上附加一个:

    UILongPressGestureRecognizer *longPressGesture =
    [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
    [cell addGestureRecognizer:longPressGesture];
    [longPressGesture release];
    

    【讨论】:

    • 您好,我有同样的问题,我尝试了上面的公式,但它对我不起作用。还有其他解决方案吗?
    【解决方案2】:

    您能否发布更多关于您如何声明您的 tableview 的详细信息?如果它被声明为可编辑,那么您可以使用单元格右端的三行长按并拖动它,否则它将崩溃,因为视图不知道如何处理长按手势.

    【讨论】:

    • 你找到解决办法了吗?
    猜你喜欢
    • 1970-01-01
    • 2015-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多