Rap*_*eta 3 iphone objective-c ios4
老实说,我不知道如何子类化UITableView.我非常困惑,正在寻找我能得到的任何帮助.我如何进行"子类化"UITableView?我需要这样做的原因是因为我需要桌子来响应背景上的触摸,以便隐藏键盘.我试过谷歌搜索但找不到任何东西.非常感谢任何帮助!
con*_*gan 10
大多数情况下你不需要子类UITableView,所以看看你是否可以先避免这样做.如果你绝对有必要,创建一个从继承的子类UITableView,并覆盖在执行触摸相关的方法:
// 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6555 次 |
| 最近记录: |