IOS第七天(1:UiTableView 的基本用法)
2015-08-04 11:16
253 查看
***表格控件
#import "HMViewController.h" @interface HMViewController () <UITableViewDataSource> @property (weak, nonatomic) IBOutlet UITableView *tableView; @end @implementation HMViewController #pragma mark - 数据源方法 // 如果没有实现,默认是1 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } // 每个分组中的数据总数 // sction:分组的编号 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) { // 第0个分组 return 5; } else { return 18; } } // 告诉表格控件,每一行cell单元格的细节 // indexPath // @property(nonatomic,readonly) NSInteger section; 分组 // @property(nonatomic,readonly) NSInteger row; 行 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // 实例化TableViewCell时,使用initWithStyle方法来进行实例化 UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; cell.textLabel.text = [NSString stringWithFormat:@"黑马学员 %02d 期 - %04d", indexPath.section, indexPath.row]; return cell; } // 返回分组的标题文字 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [NSString stringWithFormat:@"黑马 %02d 期", section]; } - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 0) { return @"太牛叉了"; } else { return @"牛叉闪闪亮"; } } @end
相关文章推荐
- Longest Consecutive Sequence
- iOS-UIkit复习和代理的使用实现文本框限制输入字数控制
- no value specified for 'date' 的解决方法
- 队列 Queue 用链表实现队列
- 南邮 OJ 1088 Gnome Sequencing
- UIDatePicker 日期/时间选取器(滚轮)—IOS开发
- 1000多块整个插板,arduino + android 蓝牙插板的实现--屌丝版
- UI-ScrollView的使用
- String、StringBuffer和StringBuilder
- BluetoothAdapter.LeScanCallback 参考文档
- iOS多线程之NSOperation,NSOperationQueue
- PHP中 include,include_once,require,require_once的区别详解
- poj 3907 Build Your Home(任意多边形面积)
- ${pageContext.request.contextPath} JSP取得绝对路径
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- Android GUI之View测量
- Xamarin.Forms之FluentValidation(Model验证)
- easyui tabs update 强制刷新页面
- Android GUI之View测量
- NGUI Sprite Type类型详解