学习笔记
来源:互联网 发布:机房迁移网络方案 编辑:程序博客网 时间:2024/06/06 11:36
【学习笔记】tableview 简单用法,加图片,文字数组,锁定不滚动
分类: 【学习笔记】 2015-04-04 22:01 1人阅读 评论(0) 收藏 举报
// FourViewController.h
@interface FourViewController : UIViewController
import “FourViewController.h”
@interface FourViewController ()
@end
@implementation FourViewController
@synthesize text_Array1;
@synthesize text_Array2;
@synthesize text_Array3;
@synthesize picture_Array1;
@synthesize picture_Array2;
@synthesize picture_Array3;
////////////////////////////////表格栏tabbarview/////////////////////////////////////
//创建数组
NSArray*tArray1=[[NSArray alloc]initWithObjects:@”余额宝”,@”找财报”,@”娱乐宝”, nil];
text_Array1=tArray1;
NSArray*tArray2=[[NSArray alloc]initWithObjects:@"芝麻信用分",@"我的保障", nil];text_Array2=tArray2;NSArray*tArray3=[[NSArray alloc]initWithObjects:@"爱心捐赠", nil];text_Array3=tArray3;NSArray*pArray1=[[NSArray alloc]initWithObjects:[UIImage imageNamed:@"1"], [UIImage imageNamed:@"2"],[UIImage imageNamed:@"3"],nil];picture_Array1=pArray1;NSArray*pArray2=[[NSArray alloc]initWithObjects:[UIImage imageNamed:@"4"],[UIImage imageNamed:@"5"],nil];picture_Array2=pArray2;NSArray*pArray3=[[NSArray alloc]initWithObjects:[UIImage imageNamed:@"6"],nil];picture_Array3=pArray3;
//创建tableview关键,不要少了代理,位置自己调
UITableView*cf_tableview=[[UITableView alloc]initWithFrame:CGRectMake(0, zl_view1.bounds.size.height+nav_View.bounds.size.height+20+yhk_view3.bounds.size.height, self.view.bounds.size.width, 500) style:UITableViewStyleGrouped];
cf_tableview.delegate=self;cf_tableview.dataSource=self;[cf_tableview setScrollEnabled:NO]; //不能滚动[self.view addSubview:cf_tableview];
}
//多少组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
//每组多少个
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section==0) {
return 3;
}else if (section==1){
return 2;
}else
return 1;
}
//创建cell,导入数组内容
-(UITableViewCell*)tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath
{
static NSString*CellIdentifier=@”Cell”;
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) { cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];}if (indexPath.section==0) { cell.textLabel.text=[text_Array1 objectAtIndex:[indexPath row]]; cell.imageView.image=[picture_Array1 objectAtIndex:[indexPath row]];}else if (indexPath.section==1){ cell.textLabel.text=[text_Array2 objectAtIndex:[indexPath row]]; cell.imageView.image=[picture_Array2 objectAtIndex:[indexPath row]];}else{ cell.textLabel.text=[text_Array3 objectAtIndex:[indexPath row]]; cell.imageView.image=[picture_Array3 objectAtIndex:[indexPath row]];}return cell;
}
////////////////////////////分区的间距,头,尾////////////////////////
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 15;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- 学习笔记?
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 每日一得--*.PFX(*.p12)&个人信息交换文件
- git core.autocrlf配置 解决Windows和Linux(Mac)换行问题
- HDU 2222 Keywords Search【AC自动机|字典树】
- 46. PHP for
- 随笔
- 学习笔记
- CPU acceleration status: HAX kernel module is not installed!
- mac 安装Django
- HttpContext.Current.Cache 和 HttpRuntime.Cache
- 关于STM32 调试工具JLINK
- 4.6实践,路由器wds设置
- github入门到精通(命令和图形教程)
- Debian下Bind9简单设置
- csdn插入源代码的测试