在 UITableView 中禁用滚动(iPhone SDK 3.0) [英] disable scrolling in a UITableView (iPhone SDK 3.0)

查看:55
本文介绍了在 UITableView 中禁用滚动(iPhone SDK 3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编辑嵌入在 UITableViewCell 中的 UITextField 时,我试图在 UITableView 中禁用滚动.这只是为了防止单元格在编辑时滚动到视线之外(同时也是为了避免一些相关的单元格回收"问题).在谷歌搜索时,我看到有人提出了显而易见的建议:

I'm trying to disable scrolling in a UITableView when editing a UITextField embedded in a UITableViewCell. This is just to prevent the cell from being scrolled out of sight when edited (and also to avoid some related cell "Recycling" problems). While googling around I've seen that somebody suggested the obvious:

tableView.scrollEnabled = NO:

甚至

tableView.userInteractionEnabled = NO;

虽然这不起作用(至少对我来说...... iPhone SDK 3.0,在模拟器上尝试过)我将这些属性设置为 NO,我什至通过日志记录检查这些属性是否设置为 NO,但 UITableView 继续正常响应触摸事件.它也愉快地滚动.如果网上有人不声称这确实有效,我就不会那么担心.

This does not work though (at least for me... iPhone SDK 3.0, tried on simulator) I set these properties to NO, I even check by logging that the properties are set to NO, but the UITableView keeps on responding normally to touch events. And it also happily scrolls. I wouldn't be that worried if somebody on the net were not claiming that this actually works.

我错过了什么吗?或者是唯一的子类化 UITableView 以使其超类 (UIScrollView) 中的功能再次工作?

Am I missing something? Or is the only alternative subclassing UITableView to make a functionality available in its superclass (UIScrollView) work again?

推荐答案

您是否尝试使用self.tableView.scrollEnabled = NO;?

我经常试过网络上的代码不起作用,仅仅是因为缺少前缀 self.我刚刚试过没有问题.

I've often tried that code from the web didn't work, simply because of a lack of the prefix self. I just tried this out without a problem.

我不知道动态打开和关闭它是否有效.初始化对象时,它至少可以用于永久设置...

I don't know if this work when turning it on and off dynamically. It does at least work for permanent settings when initializing the object...

这篇关于在 UITableView 中禁用滚动(iPhone SDK 3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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