UITabView
来源:互联网 发布:织梦5.7自动内链失效 编辑:程序博客网 时间:2024/04/30 18:55
tabView继承自UIScrollView : UIView : UIResponder : NSObject
初始化方法
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;
例子:
UITableView * tableView=[[UITableViewalloc]initWithFrame:CGRectMake(0, -50,320,466)style:UITableViewStylePlain];
tabViewStyle样式
UITableViewStylePlain,
UITableViewStyleGrouped
UITabView属性
Style separatorColor tableHeaderView tableFooterView等UITabView两个重要的代理方法
UITabViewDataSource 和UITabViewDelegate
tabView的代理dataSource中必须实现的两个方法:
//返回每个分区的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
//返回cell也就是行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
dataSource中可实现也可不实现的方法//返回多少格分区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
//设置每个分区的头和脚
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
单元格重用机制
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"返回单元格");
//定义一个重用标识符
staticNSString * reuseIndentiffer=@"cell";
//可以是任意唯一的字符串//从重用队列里面按某个标示符拿可以重用的单元格
UITableViewCell * cell=[tableViewdequeueReusableCellWithIdentifier:reuseIndentiffer];
//如果重用队列里面没有可用的单元格,创建单元格
if (cell==nil)
{
cell=[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:reuseIndentiffer]autorelease];
}
return cell;//返回创建好的单元格
}
UITabViewCell初始化方法
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier;
用在-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath方法中
UITabViewCell系统自定义的四种样式
UITableViewCellStyleDefault;
UITableViewCellStyleValue1;
UITableViewCellStyleValue2,;
UITableViewCellStyleSubtitle;
UITabViewCell属性多多要非常注意了
主要有 :
backgroundView
contentView
imageView
accessoryView
textLabel
detailTextLabel
//选中单元格执行的代理方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ DetailViewController * detailView=[[DetailViewControlleralloc]init]; //关联新窗口
[self.navigationControllerpushViewController:detailViewanimated:YES]; //点击单元格推出一个新界面
[detailView release];}
//点击cell上详细视图按钮执行的代理方法
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{ DetailViewController * detailView=[[DetailViewControlleralloc]init];
[self.navigationControllerpushViewController:detailViewanimated:YES];
[detailView release];}- UITabView
- iphone UItabview
- 自定义uitabview section
- uitabview 设置背景
- 显示更多 UITabView
- 自定义uitabview section
- uitabview 自定义选中颜色
- IOS-UITabView示例
- UITabView 小实例
- UITabView/UICollectionView 全选问题
- UITabview之用法
- 关于UItabView Cell 自定义重用的 代码
- uitabview cell 奇怪的黑角
- 超全的关于UITabview 使用介绍
- 异步POST请求及加载信息到UitabView上
- sectionheadView 跟随UItabview滚动 去掉UItableview headerview黏性
- NSOPeration 之UItabView无沙盒缓存——UITabView下载图片后 从操作缓冲池清除下载操作
- NSOperation之 设置UITabView的有沙盒图片缓存——剖析内在原理
- JVM基础研究整理之六--分代垃圾回收详述2
- DEDECMS下MYSQL查询嵌套及COUNT(*)等查询结果的输出
- 【Tesseract-OCR】在VS2010环境下调用API方法---简单快速之总结
- 关于面试的准备(一)
- 在嵌入式开发中常用两种服务tftp与nfs(资源的共享与上传,下载)
- UITabView
- A*寻路算法讲解+源码DEMO演示
- [jQuery] 2.2层级选择器(包含选择器,子选择器,相邻选择器,兄弟选择器)
- 《C和指针》读书笔记(10)
- C++中函数覆盖和使用虚函数有什么区别
- 【Machine Learning】逻辑回归 Logistic Regression
- HDU2037——今年暑假不AC
- 基于X的GNOME、GTK、GDK、XLib、GLib等之间的关系
- JVM基础研究整理之七--典型配置举例1