快速表格视图滚动和后退按钮点击

发布于 2024-12-05 21:11:04 字数 480 浏览 0 评论 0原文

当我快速滚动表格视图时(使用长而快速的手势),它会在屏幕上再滚动几秒钟,显示我的单元格(比方说 3-4 秒) - 所以我很快就按下后退按钮返回到上一个屏幕:它可以工作......但是滚动会停止(在我无法再看到的屏幕上 - 所以 3-4 秒后):应用程序崩溃!每次我进行“奇特”的碰撞测试时。

我使用了自己的表格视图单元格 - 我有点不知道从哪里开始喜欢这个错误。我只能认为之前的视图试图“释放”一些显然不再显示的东西。

你们中有人有过这样的经历吗?或者您是否尝试过自己的应用程序“测试”以确保它不会像我的那样崩溃?

当然,任何帮助指示都将受到高度赞赏!

谢谢

干杯, geebee

EDIT1:感谢您的回答 - 我终于看到,如果您像我在 viewwilldisappear 而不是 viewDidDisappear 方法中那样将我的removeallobjects 放在 viewwilldisappear 中,就会发生这种行为...现在一切都很好

When I scroll my table view fast (with a long and quick gesture) so it will scroll for a few seconds more on screen displaying my cells (let's say 3-4 seconds) - and so very quickly I hit the back button to go back to the previous screen: it works... BUT then the scrolling would have come to a stop (on the screen that I cannot see anymore - so 3-4 seconds later): the app crashes! and that each time I do that "fancy" crash test.

I used my own table view cells - and I am a bit out of ideas of where to start to fond that bug. I can only think that the previous view tries to "release" something that obviously is not displayed anymore.

Has any of you experienced this? or have you tried on your own apps that "test" to ensure it will not crash like mine?

any pointer of help is of course highly appreciated!

Thanks

Cheers,
geebee

EDIT1: thanks to your answers - I finally saw that this behavior happens if you put my removeallobjects like I was doing in the viewwilldisappear instead of viewDidDisappear method... all good now

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北风几吹夏 2024-12-12 21:11:04

造成这种情况的原因似乎是您的 UITableView 的寿命比其数据源或委托更长 - 您确定它没有泄漏吗?

在数据源/委托的 dealloc 方法中,您应该设置

tableView.delegate = nil;
tableView.dataSource = nil;

The cause of this would appear to be that your UITableView is living longer than its datasource or delegate - are you sure its not leaking?

In the dealloc method for your datasource / delegate you should set

tableView.delegate = nil;
tableView.dataSource = nil;
夏天碎花小短裙 2024-12-12 21:11:04

在后退按钮操作中检查此情况。

例如

-(void)backButtonAction:(id)sender {

//If table is scrolling
 if([mTableView isDecelerating]){
    //Don't push back or condition you want to perform
}

else {
//your condition.
}

}

,我们知道 tableview 是 UIScrollview 的层次结构,我们可以使用 isDecelerating 来检查按下按钮时表格是否正在滚动。

In back button action check for this condition.

E.g

-(void)backButtonAction:(id)sender {

//If table is scrolling
 if([mTableView isDecelerating]){
    //Don't push back or condition you want to perform
}

else {
//your condition.
}

}

As we know tableview is hierarchy of UIScrollview we can use isDecelerating to check whether the table is scrolling when button is pressed.

瑶笙 2024-12-12 21:11:04

当视图停止时,它会调用其scrollView委托的一些函数,我猜这是你的ViewController。

当用户回击时,navigationController 会释放它所显示的 ViewController。因此,如果您没有将其保留在某个地方,ViewController 将被释放,并且视图将向不再存在的对象发送一条消息。

为了快速查看我是否正确,您可以在项目中添加 NSZombieEnable = YES。之后,您将获得有关崩溃的更准确信息。

我的猜测是,您会看到类似以下内容:“XXXX 消息发送到已释放的实例 [UIViewController XXXX]”

When the view stops, it calls some functions of its scrollView delegate, which is your ViewController I guess.

When the user hits back, the navigationController release the ViewController it was showing. So if YOU didn't retain it somewhere, the ViewController will be deallocated and the view will send a message to an object that doesn't exists anymore.

In order to see if I'm right really quick, you can add the NSZombieEnable = YES in your project. After that you will get more precise informations about your crash.

My guess is that you will see something like : "XXXX message send to a deallocated instance [UIViewController XXXX]"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文