关于tableView的简单实例
关于tableCell选中颜色
//无色
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//蓝色
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//灰色
cell.selectionStyle = UITableViewCellSelectionStyleGray;
设置tableViewCell间的分割线的颜色
[theTableView setSeparatorColor:[UIColor xxxx ]];
自定义UITableViewCell选中时背景
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];
还有字体颜色
cell.textLabel.highlightedTextColor = [UIColor xxxcolor]; [cell.textLabel setTextColor:color];//设置cell的字体的颜色
改变UITableViewCell选中时背景色:
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];
我自己的一个实例:
#import "AndyViewController.h"
@interfaceAndyViewController ()
@end
@implementation AndyViewController
- (void)viewDidLoad
{
[superviewDidLoad];
NSArray *array=[[[NSArrayalloc] initWithObjects:@"monday",@"tunesday",@"thursday",@"firday",@"staturday",@"sunday",nil] autorelease];
self.listdata=array;
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)dealloc
{
[super dealloc];
[_listdatarelease];
[_tableViewrelease];
}
#pragma UITableViewDataSourc delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.listdata count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
staticNSString *identifier=@"SimpleTableIdentifier";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if(cell==nil)
{
cell=[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identifier];
}
cell.imageView.image=[UIImageimageNamed:@"star.png"];
cell.textLabel.textColor=[UIColorredColor];
cell.textLabel.text=[self.listdataobjectAtIndex:indexPath.row];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 90;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *message=[self.listdata objectAtIndex:indexPath.row];
UIAlertView *alert=[[UIAlertViewalloc] initWithTitle:@"you have selected "message:message delegate:selfcancelButtonTitle:@"取消"otherButtonTitles: nil];
[alert show];
}
@end
关于tableView的简单实例的更多相关文章
- Hibernate(二)__简单实例入门
首先我们进一步理解什么是对象关系映射模型? 它将对数据库中数据的处理转化为对对象的处理.如下图所示: 入门简单实例: hiberante 可以用在 j2se 项目,也可以用在 j2ee (web项目中 ...
- 最新 Eclipse IDE下的Spring框架配置及简单实例
前段时间开始着手学习Spring框架,又是买书又是看视频找教程的,可是鲜有介绍如何配置Spring+Eclipse的方法,现在将我的成功经验分享给大家. 本文的一些源代码来源于码农教程:http:// ...
- 修改js confirm alert 提示框文字的简单实例
修改js confirm alert 提示框文字的简单实例: <!DOCTYPE html> <html> <head lang="en"> & ...
- 利用navicat创建存储过程、触发器和使用游标的简单实例
利用navicat创建存储过程.触发器和使用游标的简单实例 标签: navicat存储过程触发器mysql游标 2013-08-03 21:34 15516人阅读 评论(1) 收藏 举报 分类: 数 ...
- 【转】Android Https服务器端和客户端简单实例
转载地址:http://blog.csdn.net/gf771115/article/details/7827233 AndroidHttps服务器端和客户端简单实例 工具介绍 Eclipse3.7 ...
- Centos7的安装、Docker1.12.3的安装,以及Docker Swarm集群的简单实例
目录 [TOC] 1.环境准备 本文中的案例会有四台机器,他们的Host和IP地址如下 c1 -> 10.0.0.31 c2 -> 10.0.0.32 c3 -> 10.0.0. ...
- vue路由的简单实例
vue2.0 和 vue1.0 路由的语法还是有点稍微的差别,下面介绍一下vue-router 2的简单实例: <!DOCTYPE html> <html lang="en ...
- Flume概述和简单实例
Flume概述 Flume是一个分布式.可靠.和高可用的海量日志采集.聚合和传输的系统.支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume提供对数据进行简单处理,并写到各种数据接受方( ...
- jsoup解析HTML及简单实例
jsoup 中文参考文献 http://www.open-open.com/jsoup/ 本文将利用jsoup,简单实现网络抓取的功能,并给出一个小实例,该实例效果为:获取作者本人在博客园写的所 ...
随机推荐
- numpy 札记
transpose 在处理caffe读入的图片数据时,需要将原始图片的数据 H*W*3(height*width*RGB) 转换为 3*H*W(RGB*heigth*width) 需要用到numpy的 ...
- java反射机制(笔记)
java反射机制就是获取出class的相应方法 例如 获取构造函数: 模版: Class test = Class.forName("cn.test.Person");//得到相应 ...
- Unix/Linux环境C编程入门教程(6) 安装Fedora C/C++开发环境
安装Fedora C/C++开发环境 1 Fedora 是一个开放的.创新的.前瞻性的操作系统和平台,基于 Linux. 2.选择自定义配置 3.设置版本为10.0 4.选择稍后安装 5.选择64位 ...
- Oracle转移user表空间位置
1:登录sqlplus sqlplus /nolog conn sys/bcc@gis as sysdba 2:修改表空间位offline alter tablespace users offline ...
- hdu 1210_(逻辑训练)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1210 #include<stdio.h> int main() { int n,t,sum ...
- &&与||的用法总结
a() && b() :如果执行a()后返回true,则执行b()并返回b的值:如果执行a()后返回false,则整个表达式返回a()的值,b()不执行: a() || b() :如果 ...
- Dynamics CRM 2013 初体验(1):系统的安装
最近收到Microsoft的Dynamics CRM 2013 beta测试邀请,终于让我掀开了它神秘的面纱.自从去年的Dynamics CRM 2012 December补丁包发布后,系统就添加了很 ...
- hdu 2850 Load Balancing (优先队列 + 贪心)
题目大意: 怎么分配n个任务到m个server上使得负载尽量平衡. 思路: 将任务从大到小排序,依次放入负载最小的那个server中. 由于是spj 的缘故,所以能够使用这个贪心. 比方数据 6 2 ...
- .net 文件下载
/** 输入参数* _Request: Page.Request 对象* _Response: Page.Response 对象* _fileName: 下载文件名* _fullPath: 带文件名下 ...
- 优质UI的7条准则(一)
本文原文来自于 Medium:https://medium.com/@erikdkennedy/7-rules-for-creating-gorgeous-ui-part-1-559d4e805cda ...