用鼠标右键点击 界面中的 ! 小圆钮,然后将 $ 中的
拖到面板中的 控件上。这样就将变量和控件建立起联系了。
和 中不同的是,要将变量和布局文件里的控件建立联系。我们是使用 %&
方法,通过控件的 找到相应的控件。
'、以下须要在 ! 文件里,处理一些数据,首先须要在 ( 方法里
载入几条測试的数据。代码例如以下:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from
a nib.
//在这里载入一些数据。用于显示在 UITableView 上面
[self loadData];
}
#pragma mark 载入一些数据,用于显示在 UITableView 上
- (void)loadData {
//初始化数组
self.tableDataArr = [NSMutableArray array];
//加入 20 个字符串到数组中
for(int i = 0; i < 20; i++) {
[self.tableDataArr addObject:[NSString
stringWithFormat:@"table item %i", i]];
}
}
这里是直接用循环生成了 ) 条 数据。
*、实现 $ 中的两个方法:
+,-.#/0-12/,$340
-.#/,1,和
+,-!12/0-12/,
5467"0-.67"12/67"1
代码例如以下:
<span style="font-size:14px;">#pragma mark 该方法返回 UITableView 中的
item 个数
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [self.tableDataArr count];
}
#pragma mark 该方法返回 UITableView 中每一个单元格,在这里处理每一个单元格中该
显示什么数据
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
评论0
最新资源