IOS7(新UI之自定义UITableViewCell)

ios7 新升级之后界面有了很大的变化,xcode模拟器去掉了手机边框和home键,如果想回到主页面,可以按住shift+comment+r键。废话少说先展示一下新UI下UItableView设置为Group后的效果:



整体界面显得更加简洁,而且UITableViewCell的宽度默认为满屛,也取消了圆角。

下面说下自定义UITableView的过程:

首先在storyboard中给cell拖过来一个UIimageView和两个label 



然后新建一个MyCell类继承自UITableViewCell。

MyCell代码:

[objc]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. //  MyCell.h  
  2. //  XcodeTest  
  3. //  
  4. //  Created by wildcat on 13-11-7.  
  5. //  Copyright (c) 2013年 wildcat. All rights reserved.  
  6. //  
  7.   
  8. #import <UIKit/UIKit.h>  
  9.   
  10. @interface MyCell : UITableViewCell  
  11. @property (weak, nonatomic) IBOutlet UIImageView *myImageView;  
  12. @property (weak, nonatomic) IBOutlet UILabel *nameLabel;  
  13. @property (weak, nonatomic) IBOutlet UILabel *timeLabel;  
  14.   
  15. @end  

[objc]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. //  MyCell.m  
  2. //  XcodeTest  
  3. //  
  4. //  Created by wildcat on 13-11-7.  
  5. //  Copyright (c) 2013年 wildcat. All rights reserved.  
  6. //  
  7.   
  8. #import "MyCell.h"  
  9.   
  10. @implementation MyCell  
  11.   
  12. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier  
  13. {  
  14.     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];  
  15.     if (self) {  
  16.         // Initialization code  
  17.     }  
  18.     return self;  
  19. }  
  20.   
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated  
  22. {  
  23.     [super setSelected:selected animated:animated];  
  24.   
  25.     // Configure the view for the selected state  
  26. }  
  27. #pragma mark 设置Cell的边框宽度  
  28. - (void)setFrame:(CGRect)frame {  
  29.     frame.origin.x += 10;  
  30.     frame.size.width -= 22 * 10;  
  31.     [super setFrame:frame];  
  32. }  
  33.   
  34. @end  


使用:

在UITableViewController中使用,代码如下:


[objc]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. //  
  2. //  RootViewController.m  
  3. //  XcodeTest  
  4. //  
  5. //  Created by wildcat on 13-11-7.  
  6. //  Copyright (c) 2013年 wildcat. All rights reserved.  
  7. //  
  8.   
  9. #import "RootViewController.h"  
  10. #import "MyCell.h"  
  11. @interface RootViewController ()  
  12.   
  13. @end  
  14.   
  15. @implementation RootViewController  
  16.   
  17. - (id)initWithStyle:(UITableViewStyle)style  
  18. {  
  19.     self = [super initWithStyle:style];  
  20.     if (self) {  
  21.         // Custom initialization  
  22.     }  
  23.     return self;  
  24. }  
  25.   
  26. - (void)viewDidLoad  
  27. {  
  28.     [super viewDidLoad];  
  29.       
  30.   
  31. }  
  32.   
  33. - (void)didReceiveMemoryWarning  
  34. {  
  35.     [super didReceiveMemoryWarning];  
  36.     // Dispose of any resources that can be recreated.  
  37. }  
  38.   
  39. #pragma mark - Table view data source  
  40.   
  41. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView  
  42. {  
  43.     return 2;  
  44. }  
  45.   
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  
  47. {  
  48.     return 3;  
  49. }  
  50.   
  51. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  
  52. {  
  53.     static NSString *CellIdentifier = @"Cell";  
  54.     MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];  
  55.       
  56.     if (cell==nil) {  
  57.         cell=[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];  
  58.     }  
  59.       
  60.     cell.nameLabel.text=@"WildCat";  
  61.     cell.timeLabel.text=@"2013-11-7";  
  62.     return cell;  
  63. }  
  64.   
  65. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{  
  66.   
  67.     return  75.f;  
  68. }  
  69.   
  70.   
  71. @end  

修改后的效果:


当然如果你喜欢cell满屏的效果,你完全可以不设cell的宽度。。。

转载请注明:版权所有http://1.wildcat.sinaapp.com/


智慧旅游解决方案利用云计算、物联网和移动互联网技术,通过便携终端设备,实现对旅游资源、经济、活动和旅游者信息的智能感知和发布。这种技术的应用旨在提升游客在旅游各个环节的体验,使他们能够轻松获取信息、规划行程、预订票务和安排食宿。智慧旅游平台为旅游管理部门、企业和游客提供服务,包括政策发布、行政管理、景区安全、游客流量统计分析、投诉反馈等。此外,平台还提供广告促销、库存信息、景点介绍、电子门票、社交互动等功能。 智慧旅游的建设规划得到了国家政策的支持,如《国家中长期科技发展规划纲要》和国务院的《关于加快发展旅游业的意见》,这些政策强调了旅游信息服务平台的建设和信息化服务的重要性。随着技术的成熟和政策环境的优化,智慧旅游的时机已经到来。 智慧旅游平台采用SaaS、PaaS和IaaS等云服务模式,提供简化的软件开发、测试和部署环境,实现资源的按需配置和快速部署。这些服务模式支持旅游企业、消费者和管理部门开发高性能、高可扩展的应用服务。平台还整合了旅游信息资源,提供了丰富的旅游产品创意平台和统一的旅游综合信息库。 智慧旅游融合应用面向游客和景区景点主管机构,提供无线城市门户、智能导游、智能门票及优惠券、景区综合安防、车辆及停车场管理等服务。这些应用通过物联网和云计算技术,实现了旅游服务的智能化、个性化和协同化,提高了旅游服务的自由度和信息共享的动态性。 智慧旅游的发展标志着旅游信息化建设的智能化和应用多样化趋势,多种技术和应用交叉渗透至旅游行业的各个方面,预示着全面的智慧旅游时代已经到来。智慧旅游不仅提升了游客的旅游体验,也为旅游管理和服务提供了高效的技术支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值