tableView 简单使用
来源:互联网 发布:牛津简明英语词典 知乎 编辑:程序博客网 时间:2024/05/22 05:21
//// ViewController.m// test//// Created by 王小胜 on 2017/2/27.// Copyright © 2017年 王小胜. All rights reserved.//#import "ViewController.h"@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor grayColor]; UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; tableView.dataSource = self; tableView.delegate = self; [self.view addSubview:tableView];}#pragma - mark cell 的点击代理方法-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *ok = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:ok]; [self.navigationController presentViewController:alert animated:YES completion:nil]; NSLog(@"点击第%ld个cell",(long)indexPath.section); }#pragma - mark dateSource- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1;}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; { return 10;}- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 2;}- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 2;}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 100;}////设置头名字//-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {// return @"测试头";//}//////设置尾名字//-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{// return @"测试尾巴";//}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc]init]; cell.textLabel.text = @"测试"; cell.imageView.image = [UIImage imageNamed:@"test"]; UITextField *textFiled = [[UITextField alloc]initWithFrame:CGRectMake(150, 2, 100, 40)]; textFiled.borderStyle = UITextBorderStyleRoundedRect; UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 42, self.view.bounds.size.width, 20)]; [cell addSubview:view]; [cell addSubview:textFiled]; return cell;}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- 简单tableView的使用
- tableView 简单使用
- Qt TableView的简单使用
- Qt TableView的简单使用
- QT tableview的简单使用
- iOS--TableView的简单使用
- Qt TableView的简单使用
- Qt TableView的简单使用
- Qt TableView的简单使用
- IOS Xcode5 IB tableView 简单使用
- UIKit-TableView--简单的TableView
- TableView使用
- IOS_简单创建tableView并使用自定义的单元格
- ios开发中最简单的tableview使用一
- iOS开发系列----UI(简单TableView的使用)
- 简单的TableView通讯录
- 自定义简单的TableView
- 简单的tableView
- QML 的 font 与 Canvas 的中 font
- logstash + grok 正则语法
- 第一篇博客(我的两年经历)
- HTTP详解(1)-工作原理
- 手写JSON解析框架
- tableView 简单使用
- 解读jquery
- Android 取得应用程序的启动次数和运行时间等信息
- Android性能优化典范
- 0228CSS学习
- 定理大全
- CSS定位
- java中Scanner
- maven下载jar包