IOS7学习之路一(新UI之自定义UITableViewCell)
ios7 新升级之后界面有了很大的变化,xcode模拟器去掉了手机边框和home键,如果想回到主页面,可以按住shift+comment+r键。废话少说先展示一下新UI下UItableView设置为Group后的效果:
整体界面显得更加简洁,而且UITableViewCell的宽度默认为满屛,也取消了圆角。
下面说下自定义UITableView的过程:
首先在storyboard中给cell拖过来一个UIimageView和两个label
然后新建一个MyCell类继承自UITableViewCell。
MyCell代码:
// MyCell.h
// XcodeTest
//
// Created by wildcat on 13-11-7.
// Copyright (c) 2013年 wildcat. All rights reserved.
// #import <UIKit/UIKit.h> @interface MyCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *myImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel; @end
// MyCell.m
// XcodeTest
//
// Created by wildcat on 13-11-7.
// Copyright (c) 2013年 wildcat. All rights reserved.
// #import "MyCell.h" @implementation MyCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
} - (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated]; // Configure the view for the selected state
}
#pragma mark 设置Cell的边框宽度
- (void)setFrame:(CGRect)frame {
frame.origin.x += 10;
frame.size.width -= 2 * 10;
[super setFrame:frame];
} @end
使用:
在UITableViewController中使用,代码如下:
//
// RootViewController.m
// XcodeTest
//
// Created by wildcat on 13-11-7.
// Copyright (c) 2013年 wildcat. All rights reserved.
// #import "RootViewController.h"
#import "MyCell.h"
@interface RootViewController () @end @implementation RootViewController - (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad]; } - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell==nil) {
cell=[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
} cell.nameLabel.text=@"WildCat";
cell.timeLabel.text=@"2013-11-7";
return cell;
} -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 75.f;
} @end
修改后的效果:
当然如果你喜欢cell满屏的效果,你完全可以不设cell的宽度。。。
转载请注明:版权所有http://1.wildcat.sinaapp.com/
IOS7学习之路一(新UI之自定义UITableViewCell)的更多相关文章
- IOS学习之路七(通过xib自定义UITableViewCell)
一.新建iOS Application工程,选择Single View Application,不要选中Use Storyboard.假设指定的是product name是:UITableViewCe ...
- IOS7学习之路三(UISpriteKit游戏开发SKNode)
ios7新添加了自己的游戏开发框架UISpriteKit ,可以用此做一些2D的小游戏, 今天学习了一下SKNode的知识做一下笔记,以便以后查阅. 1.SKNode继承自UIResponder. 2 ...
- IOS7学习之路九(ios7自定义UIAlertView)
IOS7的UIAlertView 不支持自定义,无法添加subview . 不过可以用第三方库git上的下载链接 https://github.com/wimagguc/ios-custom-a ...
- ios7学习之路六(隐藏状态栏 )
方法一(代码设置): 现在ios7已经更改为透明,并且不占用屏幕高度.其中隐藏及显示的方法如下: 在uiviewcontroller的子类下,调用: if ([self respondsTo ...
- IOS7学习之路二(处理ios6到ios7后UITableView的两个显示问题)
1.在ios6开发的项目,当用ios7的虚拟机显示的时候会出现UINavigationItem遮挡TableView的问题: 下面是对比显示效果: 我的处理方法是: 在UITableViewContr ...
- IOS7学习之路十(百度地图API环境搭建)
百度地图官网的API开发教程链接:点击打开链接 我按照他的教程做的总出现"Apple Mach-O linker command failed with exit code 1"的 ...
- IOS7学习之路八(iOS 禁止屏幕旋转的方法)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { retu ...
- ios7学习之路七(隐藏虚拟键盘,解决键盘挡住UITextField问题)
再正式开始之前,先来介绍一下IOS的键盘类型: 一.键盘风格 UIKit框架支持8种风格键盘 typedef enum { UIKeyboardTypeDefault, // 默认键盘:支持所有字符 ...
- USB小白学习之路(3) 通过自定义请求存取外部RAM
通过自定义请求存取外部RAM 1. 实验简述 此实验是对自定义的供应商特殊命令(vendor specific command bRequest = 0xA3)进行解析,程序中的read me说明如下 ...
随机推荐
- linux_常用命令_(ls, lsof,nslookup)_查看文件按照时间排序
平时收集些用到的命令 方便使用 1: ls -lrt 按时间排序 展示 2:nslookup 查看dns解析 3:lsof -p 进程号 lsof `which httpd` //那个进程在使用 ...
- 如何监控第三方应用程序(SOAP or RESTful client)访问HTTPS当数据站点?
随着越来越多的互联网应用,在我们日常的开发和调试,其中(例如,调试SOAP和RESTFul什么时候),我们经常需要访问工具,通过第三方获取HTTPS网站.为了简化叙述说明,如本文所用,IE浏览器访问G ...
- Cocos2d-xvision3.0加载失败,和,Vs2012环境搭建
1.安装好VS2012,下载Cocos2d-x3.0 双击击win32 sln运行VS2012 如果加载失败点击程序运行,输入devenv.exe /resetuserdata 回车,然后再进入VS, ...
- 【转】简述什么是Web服务(Web Service)技术?
Web Service 是在 Internet 上进行分布式计算的基本构造块,是组件对象技术在 Internet 中的延伸,是一种部署在Web 上的组件.它融合了以组件为基础的开发模式和 ...
- jQuery插件——多级联动菜单
jQuery插件——多级联动菜单 引言 开发中,有好多地方用到联动菜单,以前每次遇到联动菜单的时候都去重新写,代码重用率很低,前几天又遇到联动菜单的问题,总结了下,发现可以开发一个联动菜单的功能,以后 ...
- Performing User-Managed Database-18.4、Restoring Datafiles and Archived Redo Logs
18.4.Restoring Datafiles and Archived Redo Logs 假定介质故障损坏的一个或多个数据文件,数据文件必须恢复损坏的文件之前恢复. 该位置是不是想恢复原来姿势. ...
- ios 8 地图定位
在xcode6在 苹果公司定位方法改变地图,谁也无法使用 错误说明:Trying to start MapKit location updates without prompting for loca ...
- PCL点云库中怎样读取指定的PCD文件,又一次命名,处理后保存到指定目录
我一直想把处理后的pcd文件重命名,然后放到指定的目录,尝试了好久最终做到了: 比方我想读取 "table_scene_lms400.pcd" 把它进行滤波处理,重命名为 &qu ...
- PHP学习笔记----IIS7下安装配置php环境
原文:PHP学习笔记----IIS7下安装配置php环境 Php如何安装 Php版本的选择 Php在windows下的(php5.4.7)有两种版本: VC9 x86 Non Thread Safe ...
- MVC 使用jQuery上传文件
在ASP.NET MVC Framework中,上传文件真是超级简单,看代码: View <formaction="<%=Url.Action("Process&quo ...