简单表视图
来源:互联网 发布:通信录管理系统c语言 编辑:程序博客网 时间:2024/06/10 04:46
只能说自己能力太差,刚开始学习表视图,错误百出,又是折腾几天,才整明白个简单的表视图。现在总结下基于StoryBoard和自定义的表视图:
一,基于StoryBoard的表视图:
1,新建一个TableTest工程,打开故事板,将原来的ViewController给删掉,重新添加一个 Table View Controller;
2,将ViewController.h文件中的@interface ViewController :UIViewController改成:@interface ViewController : UITableViewController;
3,在Table View controller Scene中,点击table view controller,将标识检查器下的class改为ViewController,如下图(1);
4,将table view属性检查器下的content设置为 DynamicPrototypes(动态表),并将prototype cells 设置为0,如图(2);
#import <UIKit/UIKit.h>
@interface ViewController :UITableViewController
@property(nonatomic,strong)NSArray *listTeams;
@end
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[superviewDidLoad];
NSBundle *bundle=[NSBundlemainBundle];
NSString *plistPath=[bundlepathForResource:@"team"ofType:@"plist"];
self.listTeams=[[NSArrayalloc]initWithContentsOfFile:plistPath];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//这两个方法是必须实现的
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [self.listTeamscount];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//CellIndentifier是重用单元格标识符
staticNSString *CellIndentifier=@"CellIndentifier";
UITableViewCell *cell=(UITableViewCell *)[tableViewdequeueReusableCellWithIdentifier:CellIndentifier];
//我们将prototype属性设置为0了,因此我们需要通过代码来实现单元格的创建
if(cell==nil){
cell=[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIndentifier];
}
NSUInteger row=[indexPathrow];
NSDictionary *rowDict=[self.listTeamsobjectAtIndex:row];
cell.textLabel.text=[rowDictobjectForKey:@"name"];
NSString *imagePath=[rowDictobjectForKey:@"image"];
imagePath=[imagePathstringByAppendingString:@".png"];
cell.imageView.image=[UIImageimageNamed:imagePath];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
@end
- 创建简单表视图
- 简单表视图
- 简单表视图
- 简单分节表视图
- IOS_简单的表视图
- UITableView表视图简单使用
- IOS 创建简单表视图
- Iphone表视图的简单操作
- Iphone表视图的简单操作
- iOS开发那些事--简单表视图
- 表视图的简单使用-UITableView
- oracle 视图创建和操作,创建简单,复杂的视图,创建基表不存在的视图,视图增删改,查看视图的结构
- oracle 视图创建和操作,创建简单,复杂的视图,创建基表不存在的视图,视图增删改,查看视图的结构
- 转:oracle 视图创建和操作,创建简单,复杂的视图,创建基表不存在的视图,视图增删改,查看视图的结构
- oracle 视图创建和操作,创建简单,复杂的视图,创建基表不存在的视图,视图增删改,查看视图的结构
- oracle 视图创建和操作,创建简单,复杂的视图,创建基表不存在的视图,视图增删改,查看视图的结构
- oracle 视图创建和操作,创建简单,复杂的视图,创建基表不存在的视图,视图增删改,查看视图的结构
- UI - 简单封装视图
- IOS多线程编程笔记与NSRunLoop学习
- 【HDU】4916 Count on the path 树型DP
- 当你打开vim没有sudo 又想保存时......
- 字符串字面值与标准库string类型不是同一种类型
- vehicles or weapons were seen
- 简单表视图
- java正则
- 为什么用卷积滤波,而不是很简单的在频率领域内进行数据的频率处理
- php 命名空间
- JSON.stringify 语法实例讲解
- 获取硬盘序列号,CPU,mac地址等信息 win7下也行
- Gstreamer的一些基本概念与A/V同步分析
- zoj2588(割边)
- protobuf,thrift,avro之序列化性能测试