Mar*_*tin 14 iphone uitableview uitextview
我在自定义UITableViewCell中有一个UITextView.textview工作正常(滚动,显示文本等),但我需要用户能够点击表格单元格并转到另一个屏幕.现在,如果您点击表格单元格的边缘(即在UItextView之外),则会正确调用下一个视图.但是在uitextview中显然正在捕获触摸而不是转发到表格单元格.
我发现了一篇帖子,谈到了将UITextView子类化以转发触摸.我没试过就试过了.实施如下.我想知道是否可能a)我的textview的超级不是uitableviewcell因此我需要通过其他方式传递触摸或b)如果超级是uitableviewcell,如果我需要传递其他东西?任何帮助将非常感激.
#import "ScrollableTextView.h"
@implementation ScrollableTextView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (parentScrollView) {
[parentScrollView touchesBegan:touches withEvent:event];
}
[super touchesBegan:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
if (parentScrollView) {
[parentScrollView touchesCancelled:touches withEvent:event];
}
[super touchesCancelled:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (parentScrollView) {
[parentScrollView touchesEnded:touches withEvent:event];
}
[super touchesEnded:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if (parentScrollView) {
[parentScrollView touchesMoved:touches withEvent:event];
}
[super touchesMoved:touches withEvent:event];
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
@end
Run Code Online (Sandbox Code Playgroud)
gre*_*reg 33
尝试[theTextView setUserInteractionEnabled:NO]; 如果用户需要能够编辑TextView的内容,那么您可能会遇到设计问题.
斯威夫特3: theTextView.isUserInteractionEnabled = false
故事板:勾选"启用用户交互"复选框.
| 归档时间: |
|
| 查看次数: |
8786 次 |
| 最近记录: |