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)的更多相关文章

  1. IOS学习之路七(通过xib自定义UITableViewCell)

    一.新建iOS Application工程,选择Single View Application,不要选中Use Storyboard.假设指定的是product name是:UITableViewCe ...

  2. IOS7学习之路三(UISpriteKit游戏开发SKNode)

    ios7新添加了自己的游戏开发框架UISpriteKit ,可以用此做一些2D的小游戏, 今天学习了一下SKNode的知识做一下笔记,以便以后查阅. 1.SKNode继承自UIResponder. 2 ...

  3. IOS7学习之路九(ios7自定义UIAlertView)

    IOS7的UIAlertView 不支持自定义,无法添加subview . 不过可以用第三方库git上的下载链接    https://github.com/wimagguc/ios-custom-a ...

  4. ios7学习之路六(隐藏状态栏 )

    方法一(代码设置): 现在ios7已经更改为透明,并且不占用屏幕高度.其中隐藏及显示的方法如下: 在uiviewcontroller的子类下,调用:      if ([self respondsTo ...

  5. IOS7学习之路二(处理ios6到ios7后UITableView的两个显示问题)

    1.在ios6开发的项目,当用ios7的虚拟机显示的时候会出现UINavigationItem遮挡TableView的问题: 下面是对比显示效果: 我的处理方法是: 在UITableViewContr ...

  6. IOS7学习之路十(百度地图API环境搭建)

    百度地图官网的API开发教程链接:点击打开链接 我按照他的教程做的总出现"Apple Mach-O linker command failed with exit code 1"的 ...

  7. IOS7学习之路八(iOS 禁止屏幕旋转的方法)

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { retu ...

  8. ios7学习之路七(隐藏虚拟键盘,解决键盘挡住UITextField问题)

    再正式开始之前,先来介绍一下IOS的键盘类型: 一.键盘风格 UIKit框架支持8种风格键盘 typedef enum { UIKeyboardTypeDefault, // 默认键盘:支持所有字符 ...

  9. USB小白学习之路(3) 通过自定义请求存取外部RAM

    通过自定义请求存取外部RAM 1. 实验简述 此实验是对自定义的供应商特殊命令(vendor specific command bRequest = 0xA3)进行解析,程序中的read me说明如下 ...

随机推荐

  1. android之【本地通知Notification】

    public class NotificationTest extends Activity { static final int NOTIFICATION_ID = 0x1123; @Overrid ...

  2. 教你一步一步部署.net免费空间OpenShift系列之三------上传ASP.net程序

    接上回书,创建应用后,我们如何将自己的ASP.Net部署到应用空间呢,这里用WinSCP的SFTP协议进行上传和下载 上传ASP.net程序 下载WinSCP,并打开PuTTYGen 点击Genera ...

  3. HQL语句大全

    第 15 章 HQL: Hibernate查询语言 Hibernate配备了一种很强大的查询语言,这样的语言看上去很像SQL.可是不要被语法结构 上的类似所迷惑,HQL是很有意识的被设计为全然面向对象 ...

  4. 我的MYSQL学习心得(十)

    原文:我的MYSQL学习心得(十) 我的MYSQL学习心得(十) 我的MYSQL学习心得(一) 我的MYSQL学习心得(二) 我的MYSQL学习心得(三) 我的MYSQL学习心得(四) 我的MYSQL ...

  5. iptables的配置文件/etc/sysconfig/iptables不存在怎么办

    iptables的配置文件/etc/sysconfig/iptables不存在怎么办 首先要看一下iptables是否安装了,使用service iptables status或yum info ip ...

  6. Mac下一个/usr/include失踪

    Mac升级到Yosemite后,突然发现vim的YouCompleteMe代码提示所以空头支票成员,排查了一下,原本/usr/include目录中缺少.所有的C/C++头文件不见了. .. 第一次发现 ...

  7. 第5章1节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 官方简介(原创)

    天地会珠海分舵注:本来这一系列是准备出一本书的,详情请见早前博文“寻求合作伙伴编写<深入理解 MonkeyRunner>书籍“.但因为诸多原因,没有如愿.所以这里把草稿分享出来,所以错误在 ...

  8. win7 wifi 无Internet訪问权限或者有限的訪问权限

    自己家的无线路由器,手机和笔记本都使用正常,可是一台新笔记本连上之后总是提示"有限的訪问权限",无法连公网. 网上的非常多办法都无论用,什么设置静态IP或者重新启动路由,基本都是瞎 ...

  9. APP-随身听

    简单到复杂听你的专属音响界,听金融.听物业,听新闻和其他节目专辑,简要介绍了新的音频应用,给你不一样的聆听体验.还记得老歌做?这里有.您留声机的一部分!很简单的音频应用,随时随地与此应用程序来听你的私 ...

  10. leetcode第七题--Reverse Integer

    Problem: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 ...