【发布时间】:2011-09-16 11:55:03
【问题描述】:
我想要一个绘制自定义 Section 标题的 UITableView 的子类。我尝试如下:
#import <UIKit/UIKit.h>
@interface MyTableView : UITableView
@end
@implementation MyTableView
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
//my drawing code goes here
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//returns the height
}
@end
但是,当我使用此类时,它会绘制正常的标题。我做错了什么?
当我将这些函数直接设置到控制器中(没有子类化)时,它可以正常工作。
更新: 我已经有很多使用 UITableView 的类,我想对它进行子类化,因为只更改编写所需类的类可能会更快。怎么能只通过更改班级来更改标题,可以吗?
【问题讨论】:
标签: iphone objective-c ios uitableview subclassing