不继承 UITableViewController 的 UITableView 浮动表头
UITableView floating header without inheriting from UITableViewController
我有两个viewController,一个继承自UIViewController,另一个继承自UITableViewController。当我尝试做
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
}
它 运行 在 UITableViewController class 中但是当我尝试在 UIViewController class 上执行它时 class code sense 没有显示它甚至没有 运行。有人知道怎么回事吗?
在您的 ViewController Class 中,添加以下行
@interface YourClass : UIViewController <UITableViewDelegate, UITableViewDataSource>{
@property (weak, nonatomic) IBOutlet UITableView *yourTableView
}
现在在您的 viewDidLoad 中,添加以下行
_yourTableView.delegate = self;
_yourTableView.dataSource = self;
这将调用 ViewController 中 UITableView 的所有委托和数据源方法。
我有两个viewController,一个继承自UIViewController,另一个继承自UITableViewController。当我尝试做
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
}
它 运行 在 UITableViewController class 中但是当我尝试在 UIViewController class 上执行它时 class code sense 没有显示它甚至没有 运行。有人知道怎么回事吗?
在您的 ViewController Class 中,添加以下行
@interface YourClass : UIViewController <UITableViewDelegate, UITableViewDataSource>{
@property (weak, nonatomic) IBOutlet UITableView *yourTableView
}
现在在您的 viewDidLoad 中,添加以下行
_yourTableView.delegate = self;
_yourTableView.dataSource = self;
这将调用 ViewController 中 UITableView 的所有委托和数据源方法。