首页 / IOS / ios成长之每日一遍(day 8)
ios成长之每日一遍(day 8)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ios成长之每日一遍(day 8),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1660字,纯文字阅读大概需要3分钟。
内容图文
这几天都有一些任务要跟, 把ios的学习拉后, 看看要抓紧咯, 看看轮到的学习的是UITableView。
BIDViewController.h
#import <UIKit/UIKit.h> @interface BIDViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> @property (copy, nonatomic) NSArray *computers; @end
BIDViewController.m
#import " BIDViewController.h " #import " BIDNameAndColorCell.h " @implementation BIDViewController static NSString *CellTableIdentifier = @"CellTableIdentifier"; // 重用标记 - (void)viewDidLoad { [super viewDidLoad]; self.computers = @[ @{@"Name" : @"MacBook", @"Color" : @"White"}, @{@"Name" : @"MacBook Pro", @"Color" : @"Silver"}, @{@"Name" : @"iMac", @"Color" : @"Silver"}, @{@"Name" : @"Mac Mini", @"Color" : @"Silver"}, @{@"Name" : @"Mac Pro", @"Color" : @"Silver"}]; // 为NSArray赋数值 UITableView *tableView = (id)[self.view viewWithTag:1]; // 这个view是controller管理的, viewWithTag是根据设定的tab tableView.rowHeight = 65; // 设置每行的高度 UINib *nib = [UINib nibWithNibName:@"BIDNameAndColorCell" bundle:nil]; [tableView registerNib:nib forCellReuseIdentifier:CellTableIdentifier]; } #pragma mark - #pragma mark Table Data Source Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.computers count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { BIDNameAndColorCell *cell = [tableView dequeueReusableCellWithIdentifier:CellTableIdentifier]; NSDictionary *rowData = self.computers[indexPath.row]; cell.name = rowData[@"Name"]; cell.color = rowData[@"Color"]; return cell; } @end
原文:http://www.cnblogs.com/lee0oo0/p/3761337.html
内容总结
以上是互联网集市为您收集整理的ios成长之每日一遍(day 8)全部内容,希望文章能够帮你解决ios成长之每日一遍(day 8)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】