ios - 在 UITableViewCell 中滚动 UITextView

标签 ios uitableview uitextview

我已将 UITextView 放入 UITableViewCell,但无法滚动文本。当我尝试滚动 textView 时,tableView 捕捉到了触摸。

有什么办法可以解决这个问题吗?

PS:UITableViewController的子类

最佳答案

我认为您可以检测正在触摸的对象,如果它是 UITextView,则暂时禁用 UITableView 的滚动:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
     [super touchesBegan:touches withEvent:event];
     UITouch *touch = [touches anyObject];

     //detect if touch is on UITextView
     if ([touch.view isKindOfClass: UITextView.class]) {
         yourTableView.scrollEnabled = NO;
     }
}

不要忘记在touchesEnded之后重新启用UITableView的滚动

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        yourTableView.scrollEnabled = YES;
}

关于ios - 在 UITableViewCell 中滚动 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20637210/

相关文章:

ios - 搜索 Youtube API 时描述被截断

ios - Xcode仪器: Memory Terms Live Bytes and Overall Bytes (Real Memory) confusion

ios - 填充 Tableview 时发送到实例的无法识别的选择器

ios - 如果行数据与前一行匹配,则对 UITableView 中的行进行编号并复制行号

swift - 如何正确设置 UITextView

ios - 以编程方式将文本插入 UITextView 而不移动插入符号位置。

php - MySQL、UTF-8 和 Emoji 字符

swift : How to instantiate a new view controller with separate delegate

ios - iOS 中突出显示的文本(类似卡拉 OK 的应用程序)

ios - 在 iOS 5 中刷新 JSON 表