如何在TableView下面添加View?
How to add the View below the TableView?
如何在UITableView
下面添加View
(ImageView
)?
并且可以使用 UITableView
滚动视图
因为我的TableItem
可以展开
您需要实现 UITableViewDelegate 方法
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
和 return table.
的相应部分所需的视图(例如,在页脚中包含您想要的文本的 UILabel)
有点像下面。
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 30.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *sampleView = [[UIView alloc] init];
sampleView.frame = CGRectMake(x, y, width, height);
sampleView.backgroundColor = [UIColor blackColor];
return sampleView;
}
并包含 UITableViewDelegate 协议。
@interface TestViewController : UIViewController <UITableViewDelegate>
如何在UITableView
下面添加View
(ImageView
)?
并且可以使用 UITableView
因为我的TableItem
可以展开
您需要实现 UITableViewDelegate 方法
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
和 return table.
的相应部分所需的视图(例如,在页脚中包含您想要的文本的 UILabel)有点像下面。
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 30.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *sampleView = [[UIView alloc] init];
sampleView.frame = CGRectMake(x, y, width, height);
sampleView.backgroundColor = [UIColor blackColor];
return sampleView;
}
并包含 UITableViewDelegate 协议。
@interface TestViewController : UIViewController <UITableViewDelegate>