我已将 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/