长按表格视图时崩溃 [英] Crash while long press on the tableview

查看:56
本文介绍了长按表格视图时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i have one tableview that have custom cells and one cell contains uiimageview,uilabels . When I pressed and hold and move uitableviewcell , sometimes I get crash with this logs.How can I remove this crash. I didn't use any gesture recognizer in my app and also i didn't use any tap or touch detection.I used only tableview delegate and datasource methods. Thanx for any help!

'-[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
)


推荐答案

您可以尝试通过添加一个来拦截呼叫到你的细胞。这与在编辑模式下拖动和移动单元格的能力没有冲突。

You can try intercepting the call by adding one to your cells. This does not conflict with the ability to drag and move cells in the edit mode. My table works fine for both.

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

In my - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

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

I attach one to each cell:

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

这篇关于长按表格视图时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆