IOS学习 UITableView 基本属性
来源:互联网 发布:淘宝购物流程入门教程 编辑:程序博客网 时间:2024/05/19 15:44
删除空白行
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
#import <UIKit/UIKit.h>
#define VIEW_WIDTH self.view.bounds.size.width
#define VIEW_HEIGHT self.view.bounds.size.height
@interface HomeViewController :UIViewController<UITableViewDataSource>
{
UITableView *_tableView;
}
@property (nonatomic,retain)NSArray *listArray;
@end
@implementation HomeViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
self.listArray = [UIFontfamilyNames];//所有字体名称
_tableView = [[UITableViewalloc]initWithFrame:CGRectMake(0,20,VIEW_WIDTH,VIEW_HEIGHT-20)style:UITableViewStylePlain];
//实现数据源方法
_tableView.dataSource =self;
//设置行高,默认为44
_tableView.rowHeight =60;
//设置表视图的背景色,需先清除单元格和背景视图默认的白色背景
_tableView.backgroundView =nil;//清除背景视图默认的白色背景
// _tableView.backgroundColor = [UIColor yellowColor];
//设置表视图的图片
_tableView.backgroundView =nil;
UIImageView *imageView = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"background5.jpg"]];
_tableView.backgroundView = imageView;
//设置表视图的分割线
_tableView.separatorColor = [UIColorpurpleColor];
_tableView.separatorStyle =UITableViewCellSeparatorStyleNone;//隐藏分割线
/* UITableViewCellSeparatorStyleSingleLine;单线
UITableViewCellSeparatorStyleSingleLineEtched; ??*/
//设置表视图的头部视图 HeaderView添加子视图
UIView *headerView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,VIEW_WIDTH,60)];
// headerView.backgroundColor = [UIColor purpleColor];
_tableView.tableHeaderView = headerView;
UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(100,0,VIEW_WIDTH-200,60)];
label.text = @"三八节快乐!";
label.textAlignment =NSTextAlignmentCenter;
label.backgroundColor = [UIColorcyanColor];
[headerView addSubview:label];
//设置表视图的尾部视图 FooterView
UIView *footerView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,VIEW_WIDTH,30)];
footerView.backgroundColor = [UIColororangeColor];
_tableView.tableFooterView = footerView;
[self.viewaddSubview:_tableView];
}
#pragma mark - UITableView DataSource
//section中包含row的数量
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return_listArray.count;
}
//创建单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIndentifier =@"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
if (cell == nil) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIndentifier];
}
NSString *fontName = [self.listArrayobjectAtIndex:indexPath.row];
cell.textLabel.text = fontName;
cell.textLabel.textColor = [UIColorredColor];
cell.textLabel.font = [UIFontfontWithName:fontNamesize:24];
//指向其中的哪一行
NSLog(@"index row :%ld",(long)indexPath.row);
NSLog(@"index section :%ld",(long)indexPath.section);
//清除单元格默认的白色背景
cell.backgroundColor=[UIColorclearColor];
return cell;
}
//表视图中存在section的个数,默认为1
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
//
//}
- IOS学习 UITableView 基本属性
- IOS UITableView 方法及属性学习
- IOS UITableView 方法及属性学习
- IOS学习:基本控件(UITableView)
- UITableView基本属性详解
- UITableView基本属性
- iOS -- UITableView基本使用
- iOS -- UITableView基本使用
- iOS学习笔记-026.UITableView的基本用法
- IOS UITableView NSIndexPath属性讲解
- iOS:UITableView 方法 属性 详解
- IOS UITableView NSIndexPath属性讲解
- iOS UITableView NSIndexPath属性讲解
- IOS UITableView NSIndexPath属性讲解***
- ios--UITableview的基本使用方法
- ios控件 UITableView 基本使用
- ios--UITableview的基本使用方法
- iOS UITableView的基本使用
- 单身的脆弱
- 前端一些概念的理解
- Python基础(三)之tuple类型
- Hibernate的单向N-1关联(一)
- [Boost基础]函数与回调——ref引用
- IOS学习 UITableView 基本属性
- android文件分段下载
- WebKit之Chromium零散知识
- C 语言分割字符串
- size_t
- 深入理解Java内存模型
- 【Eclipse】2、使用eclipse软件编译并执行代码
- 【Codeforces650C】Table Compression【并查集】【拓扑排序】
- 学生信息管理系统之问题总结(1)