我有一个UITextView到UITableViewCell,但我无法滚动文本 . 当我尝试滚动textView时,tableView grab 了触摸 .
有什么方法可以解决这个问题吗?
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; }
1 回答
我想你可以检测到被触摸的对象,如果它是UITextView,那么暂时禁用UITableView滚动:
不要忘记在touchesEnded中重新启用UITableView的滚动