自定义UITableView
来源:互联网 发布:js图片点击弹出层放大 编辑:程序博客网 时间:2024/04/28 12:56
自定义UITableView
1.controller
SpecialSaleView *view = [[SpecialSaleView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-64-44-49)];view.backgroundColor = [UIColor redColor];[self.view addSubview:view]; _specialView = view;
2.view
#import <UIKit/UIKit.h>@interface SpecialSaleView : UIView@end
#import "SpecialSaleView.h"#import "HWDConstant.h"@interface SpecialSaleView ()<UITableViewDelegate,UITableViewDataSource>@property(nonatomic,weak) UITableView * tableView;@end@implementation SpecialSaleView- (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; [self createTableView]; } return self;}- (void)layoutSubviews { [super layoutSubviews];// CGRect frame = CGRectMake(0, 0, self.width, self.height);// if (!CGRectEqualToRect(frame, _tableView.frame)) {// _tableView.frame = CGRectMake(0, 0, self.width, self.height);// }}- (void)createTableView{ UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)]; tableView.delegate = self; tableView.dataSource=self; [self addSubview:tableView]; _tableView = tableView; //headerView UIView*headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 380)]; headerView.backgroundColor=[UIColor purpleColor]; _tableView.tableHeaderView=headerView;}- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 100;}- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 10;}- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString * reuseID = @"cell"; UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:reuseID]; if (cell== nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseID]; } cell.backgroundColor = [UIColor groupTableViewBackgroundColor]; cell.textLabel.text = @"100000000"; return cell;}@end
阅读全文
0 0
- 自定义 uitableview
- 自定义UITableView
- 自定义UITableView
- UITableView实现自定义布局
- iphone自定义UITableView
- 如何自定义UITableView标题
- UITableView自定义UITableViewCell
- UITableView 自定义UITableViewCell
- UITableView实现自定义布局
- IOS - 自定义表格(UITableView)
- UITableView,自定义UITableViewCell
- UITableView自定义Section
- 自定义UITableView的Header
- 自定义UITableView各种函数
- UITableView样式的自定义
- UITableView自定义Section
- UITableView自定义选中指示
- UITableView 系列: 自定义 UITableViewCell
- js中的执行上下文和作用域
- Comparison method violates its general contract!
- IAR调试错误总结(未写完)
- Hibernate中的数据库方言(Dialect)
- MVP泛型+RecyclerView+Retrofit+OkHttp+RxJava
- 自定义UITableView
- 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
- java技术
- 字符串拼接 的 方法
- Java基础三
- java基础
- Python 中的 if __name__ == '__main__'理解
- 欢迎使用CSDN-markdown编辑器
- AWS终于支持Kubernetes,Serverless容器服务AWS Fargate同时发布