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. eclipse 组态xdebug

    1.打开浏览器打开phpinfo页面视图PHP版本号.TS(线程安全)版本NTS(非线程安全)版本.以及VC6版本号是VC9版本号 2.和上面版本号相应的xdebug:http://xdebug.or ...

  2. order by使用方法

    1.ORDER BY 中关于NULL的处理 缺省处理,Oracle在Order by 时觉得null是最大值,所以假设是ASC升序则排在最后,DESC降序则排在最前. 当然,你也能够使用nulls f ...

  3. 了解了解你自己的话zookeeper(从那时起,纠正了一些说法在线)

    1,先看看官方的定义吧: ZooKeeper is a distributed, open-source coordination service for distributed applicatio ...

  4. HDU 5055 Bob and math problem(结构体)

    主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been think ...

  5. WebService对跨域的支持

    WebService对跨域的支持 跨域问题来源于JavaScript的同源策略,即只有 协议+主机名+端口号 (如存在)相同,则允许相互访问.也就是说JavaScript只能访问和操作自己域下的资源, ...

  6. [Unity3D]Unity3D游戏开发之Unity与Android交互调用研究

    各位朋友,大家好,我是秦元培,欢迎大家关注我的博客,我的博客地址是blog.csdn.net/qinyuanpei.在前一篇文章中,我们研究了Android平台上Unity3D的手势操作并在之前的基础 ...

  7. ASP.NET Web API和ASP.NET Web MVC中使用Ninject

    ASP.NET Web API和ASP.NET Web MVC中使用Ninject 先附上源码下载地址 一.准备工作 1.新建一个名为MvcDemo的空解决方案 2.新建一个名为MvcDemo.Web ...

  8. VS2013中实现angular代码智能提示

    第一步:在项目同添加angular js文件的引用: 这里使用NuGet包管理器来给项目添加angular js install-package angularjs 第二步:添加智能提示js文件 我们 ...

  9. C# 带滚动栏的Label控件

    C# 带滚动栏的Label控件,用鼠标选的时候还是有点闪烁: namespace 带滚动栏的Label控件 { public class TextBoxLabel : System.Windows.F ...

  10. CSS背景图片定位

    原文:CSS背景图片定位 在网页开发中我们经常需要对图片进行分割(如下图)来使用,而不是分别提供单独的图片来调用,常见的如页面背景,按钮图标等,这样做的好处就是减少请求次数,节省时间和带宽. 对背景图 ...