UI tableView 的头视图 & "小广告"
来源:互联网 发布:淘宝退款率计算 编辑:程序博客网 时间:2024/04/28 21:58
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64) style:UITableViewStylePlain]; [self.view addSubview:self.tableView]; [_tableView release]; self.tableView.dataSource = self; self.tableView.delegate = self; // 设置cell行高 self.tableView.rowHeight = 100; self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -200, self.view.frame.size.width, 200)]; self.imageView.image = [UIImage imageNamed:@"5.jpg"]; // 给tableview添加头视图(不动得一张图) // 宽是tableView的宽度 self.tableView.tableHeaderView = self.imageView;
这样设置图片当你在下拉时,不会有任何改变.
可以试试以下代码的效果!
- (void)viewDidLoad {// 格外小广告 [self.tableView addSubview:self.imageView]; self.tableView.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);}#pragma mark tableView 的delegate 已经签订好了scrollView的协议,只要设置好代理人,就可以使用scrollView的协议方法.- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ CGFloat y = scrollView.contentOffset.y; if (y < 0) { self.imageView.frame = CGRectMake(0, y, self.view.frame.size.width, -y); } NSLog(@"%g",y);}
当然不要忘了写协议中的方法.
tableView有一个方法reloadData. 可以刷新数据.
0 0
- UI tableView 的头视图 & "小广告"
- tableView 头视图的高度
- TableView头视图
- iOS tableView 改变头视图和脚视图的颜色
- tableview头视图 和分区头视图
- 下拉放大tableView头视图
- 封装的轮播图作为头视图的tableview
- 点击tableview的头视图按钮来达到收放tableview的列表
- 关于iOS 11 tableView跟导航栏之间有空白和tableview的头视图问题
- 实现tableView组的头视图、尾视图的粘滞效果
- tableView plain 去除头视图悬停效果
- iOS — tableView头视图缩放效果。
- 如何设置tableView的组的头视图的高度?为什么你设置的tableView的组的头视图的高度无效呢?
- tableview头视图与 tableview中间有空隙
- UI tableView 的优化
- iOS TableView头视图根据偏移量下拉缩放的效果实现
- 自定义tableView的标题头
- TableView表视图的使用
- iOS通知:NSNotificationCenter
- linux命令(1):wget命令
- 分支18
- GitHub for Windows使用简介
- 天声人語 20150829
- UI tableView 的头视图 & "小广告"
- leetcode 160 Intersection of Two Linked Lists(难易度:Easy)
- Xargs用法详解(转载)
- UDP广播程序的实现
- LeetCode2.2.9(Reverse Nodes in k-Group)
- 8.28 Android学习日记
- 机器学习算法与Python实践之(一)k近邻(KNN)
- 如何构建自己的.jar文件
- Python -定义函数