问题描述
老实说,我不知道如何子类化 UITableView.我非常困惑,正在寻找我能得到的任何帮助.如何对 UITableView 进行子类化"?我需要这样做的原因是因为我需要表格响应背景上的触摸,以便可以隐藏键盘.我试过谷歌搜索,但找不到任何东西.非常感谢任何帮助!
I honestly don't know how to subclass a UITableView. I'm super confused and looking for whatever help I can get. How do I go about "subclassing" a UITableView? Reason I need to do it is because I need for the table to respond to touches on the background so that keyboards can be hidden. I've tried googling but couldn't find anything. Any help is extremely appreciated!
推荐答案
大多数时候你不需要子类化 UITableView,所以先看看你是否可以避免这样做.如果您绝对必须,创建一个继承自 UITableView 的子类,并在实现中覆盖与触摸相关的方法:
Most of the time you shouldn't need to subclass UITableView, so see if you can avoid doing so first. If you absolutely have to, create a subclass that inherits from UITableView and override the touch-related methods in the implementation:
// MyTableView.h
@interface MyTableView : UITableView {
}
@end
// MyTableView.m
@implementation MyTableView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event {
[super touchesCancelled:touches withEvent:event];
}
@end
这篇关于如何继承 UITableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)