博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
表格视图
阅读量:2351 次
发布时间:2019-05-10

本文共 1229 字,大约阅读时间需要 4 分钟。

   表格视图是iOS中非常重要,下面就简要介绍一下如何将数字显示到表格控制器中

1:删除原先的视图控制器,将一个Table View Controller 拖入到故事版中,修改其父类为

UITableViewController,

即在 ViewController.h文件中

#import <UIKit/UIKit.h>

@interface ViewController :UITableViewController

@end

选中表格视图控制器,打开其身份检查器,在Class属性右侧中填入ViewController类

2:为了能够通过

dequeueReusableCellWithIdentifier:forIndexPath: 方法来重复使用表格单元格对象,将单元格Style设置为Custom,Identifier属性设置为

ProvincesIdentifier,即

3:在ViewController.h

#import "ViewController.h"@interface ViewController ()@property(nonatomic,strong) NSArray *provinces;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    self.provinces = @[@"张三",@"李四",@"王五",@"张翼",@"账务",@"123",@"1234",@"23",@"230",@"236",@"237"];}#pragma mark -数据库协议-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return [self.provinces count];}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProvincesIdentifier" forIndexPath:indexPath];    cell.textLabel.text = [self.provinces objectAtIndex:[indexPath row]];    return cell;}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];   }@end
4:运行之后即为

你可能感兴趣的文章
如何通过OpenFace实现人脸识别框架
查看>>
Angle和XBGoost以及Spark的性能对比
查看>>
IOS CoreImage实现人脸识别
查看>>
Tensorflow的高级封装
查看>>
Storm 1.1.0 集群安装
查看>>
图像压缩算法
查看>>
一张图看懂小程序全生态
查看>>
electron开发
查看>>
NodeJS开发c++扩展模块
查看>>
Electron如何调用NodeJS扩展模块
查看>>
NodeJS通过ffi调用DLL
查看>>
Electron通过ffi调用DLL
查看>>
Node.js & Electron的扩展模块
查看>>
Mysql semi-sync VS group replication, 谁快?
查看>>
Android Looper Message MessageQueue Handler
查看>>
Win10下安装卸载Oracle11g的教程及各种坑
查看>>
Zookeeper
查看>>
更新mysql5.7修改字符集
查看>>
Windows系统护眼色设置
查看>>
JUC多线程&lambda之美&ThreadLocal
查看>>