首先来看下我们要实现的效果

需要实现这样的效果

然后我们开始动手吧。

首先选择添加一个新的ViewController

然后打开XIB文件,添加一UITableView 并将样式设置为分组

同时将按住CONTROL 链接dataSource与delegate

接着修改.H文件,具体代码如下

 #import <UIKit/UIKit.h>

 @interface GRXXViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
{
NSString *name;
NSString *uid;
NSString *sex;
NSString *address;
NSString *gxqm;
}
@property(nonatomic,retain) NSString *name;
@property(nonatomic,retain) NSString *uid;
@property(nonatomic,retain) NSString *sex;
@property(nonatomic,retain) NSString *address;
@property(nonatomic,retain) NSString *gxqm;
@end

GRXXViewController.h

然后我们还需要自定义一个CELL来显示相关的样式

具体样式如下

并修改.h文件和.m文件 ,同时将两个label 与代码进行绑定

 #import <UIKit/UIKit.h>

 @interface infoCell : UITableViewCell
{
UILabel *contentlabel;
UILabel *titilelabel;
}
@property(nonatomic,retain) IBOutlet UILabel *contentlabel;
@property(nonatomic,retain) IBOutlet UILabel *titilelabel;
@end

infoCell.h

 #import "infoCell.h"

 @implementation infoCell
@synthesize contentlabel;
@synthesize titilelabel;
- (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
} @end

infoCell.m

然后 选择GRXXViewController.m 文件

完成

//定义分组数

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView

//定义分组行数

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

//设置分组行头

-(NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

这几个方法

直接上代码

 #import "GRXXViewController.h"
#import "infoCell.h"
@interface GRXXViewController () @end @implementation GRXXViewController
@synthesize name;
@synthesize gxqm;
@synthesize sex;
@synthesize uid;
@synthesize address;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
name=@"请输入中文名";
uid=@"myzhanghao";
sex=@"男";
address=@"浙江温州";
gxqm=@"IOS开发中";
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark -
#pragma mark Table View Data Source Methods
//定义分组数
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return ;
}
//定义分组行数
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(section==)
return ;
else if(section==)
return ;
else
return ;
}
//设置分组行头
-(NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
// if(section==0)
// return @"基本信息";
// else if(section==1)
// return @"总计";
// else if(section==2)
// return @"与互";
// else if(section==3)
// return @"查询";
// else
return @"";
}
-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if([indexPath section]==)
{
if([indexPath row]==)
{
static NSString *modifyinfoTableIdentifier=@"LookInfoModelCell";
infoCell *cell= (infoCell *)[tableView dequeueReusableCellWithIdentifier:modifyinfoTableIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"infoCell" owner:self options:nil];
cell = [nib objectAtIndex:];
}
cell.contentlabel.text=name;
cell.titilelabel.text=@"名字:";
return cell;
}
else
{
static NSString *modifyinfoTableIdentifier=@"LookInfoModelCell";
infoCell *cell= (infoCell *)[tableView dequeueReusableCellWithIdentifier:modifyinfoTableIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"infoCell" owner:self options:nil];
cell = [nib objectAtIndex:];
}
cell.contentlabel.text=uid;
cell.titilelabel.text=@"我的账号:";
return cell;
}
}
else if([indexPath section]==)
{
if([indexPath row]==)
{
static NSString *modifyinfoTableIdentifier=@"LookInfoModelCell";
infoCell *cell= (infoCell *)[tableView dequeueReusableCellWithIdentifier:modifyinfoTableIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"infoCell" owner:self options:nil];
cell = [nib objectAtIndex:];
}
cell.contentlabel.text=sex;
cell.titilelabel.text=@"性别:";
return cell;
}
else if([indexPath row]==)
{
static NSString *modifyinfoTableIdentifier=@"LookInfoModelCell";
infoCell *cell= (infoCell *)[tableView dequeueReusableCellWithIdentifier:modifyinfoTableIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"infoCell" owner:self options:nil];
cell = [nib objectAtIndex:];
}
cell.contentlabel.text=address;
cell.titilelabel.text=@"地区:";
return cell;
}
else
{
static NSString *modifyinfoTableIdentifier=@"LookInfoModelCell";
infoCell *cell= (infoCell *)[tableView dequeueReusableCellWithIdentifier:modifyinfoTableIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"infoCell" owner:self options:nil];
cell = [nib objectAtIndex:];
}
cell.contentlabel.text=gxqm;
cell.titilelabel.text=@"个性签名:";
return cell;
} }
else
{
static NSString *modifyinfoTableIdentifier=@"LookInfoModelCell";
infoCell *cell= (infoCell *)[tableView dequeueReusableCellWithIdentifier:modifyinfoTableIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"infoCell" owner:self options:nil];
cell = [nib objectAtIndex:];
}
cell.contentlabel.text=@"展示";
cell.titilelabel.text=@"腾讯微博:";
return cell; } }@end

GRXXViewController.m

最后就完成拉

如果还想实现其他效果的 话 就自定义相关的CELL样式 同时在不同条件下使用不同样式就可以了,具体的请参照如何实心新闻页面那一章

IOS开发---菜鸟学习之路--(十七)-利用UITableView实现个人信息界面的更多相关文章

  1. IOS开发---菜鸟学习之路--(六)-UITableView几个方法的使用说明

    对于UITableView的基础使用我这边就不做重复介绍了 我重点就来介绍下如何实现大部分新闻的界面.也就是第一条记录显示大图片下面加一段文字说明 然后剩下来的内容全部显示为文字图片的格式 其实要做到 ...

  2. IOS开发---菜鸟学习之路--(二十三)-直接利用键值对的方式来处理数据的感想

    首先声明,本文纯粹只是做为本人个人新手的理解.文中的想法我知道肯定有很多地方是错的. 但是这就是我作为一个新人的使用方法,对于大牛非常欢迎指导,对于喷子请绕道而行. 由于这是早上跟我学长讨论数据处理时 ...

  3. IOS开发---菜鸟学习之路--(二十二)-近期感想以及我的IOS学习之路

    在不知不觉当中已经写了21篇内容 其实一开始是没有想些什么东西的 只是买了Air后 感觉用着挺舒服的,每天可以躺在床上,就一台笔记本,不用网线,不用电源,不用鼠标,不用键盘,干干脆脆的就一台笔记本. ...

  4. IOS开发---菜鸟学习之路--(一)

    PS(废话): 看了那么多的博客文章,发现大部分人都一直在强调写技术博客的重要性,索性自己也耐着性子写写看吧. 写博客的重要性之类的说明,我就不做复制黏贴的工作了.因为自己没有写过多少,所也不清楚是不 ...

  5. IOS开发---菜鸟学习之路--(二十一)-利用正则表达式解析URL获取其中的参数

    因为项目需要解析URL当中参数的部分,在网上搜索了一下都没有相关的资料. 然后就自己写了一个 其实我就是通过正则表达式来处理URL 进行解析的 好了直接上代码吧 也是非常的简单,大家拷贝过去就可以使用 ...

  6. IOS开发---菜鸟学习之路--(十九)-利用NSUserDefaults存储数据

    利用NSUserDefaults的可以快速的进行本地数据存储,但是支持的格式有限, 至于支持什么格式大家可以再自行脑补 我这边直接讲如何使用 NSUserDefaults 分为两部分 一个是存数据 N ...

  7. IOS开发---菜鸟学习之路--(十三)-利用MBProgressHUD进行异步获取数据

    本章将介绍如何利用MBProgressHUD实现异步处理数据. 其实我本来只是像实现一个加载数据时提示框的效果,然后问了学长知道了这个类,然后就使用了 接着就发现了一个“BUG” 再然后就发现原来MB ...

  8. IOS开发---菜鸟学习之路--(十二)-利用ASIHTTPRequest进行异步获取数据

    想要实现异步获取的话我这边了解过来有两个非常简单的方式 一个是利用ASIHTTPRequest来实现异步获取数据 另一个则是利用MBProgressHUD来实现异步获取数据 本章就先来讲解如何利用AS ...

  9. IOS开发---菜鸟学习之路--(九)-利用PullingRefreshTableView实现下拉刷新

    本章主要讲解如何利用PullingRefreshTableView实现下拉(上拉)刷新的操作 PullingRefreshTableView 实现上下拉刷新的例子百度有很多,大家可以自己搜索下,先看下 ...

随机推荐

  1. 【Linux/Ubuntu学习 11】git查看某个文件的修改历史

    有时候在比对代码时,看到某些改动,但不清楚这个改动的作者和原因,也不知道对应的BUG号,也就是说无从查到这些改动的具体原因了- [注]:某个文件的改动是有限次的,而且每次代码修改的提交都会有commi ...

  2. 再回首win98

    因为一个软件只能运行在win98上,所以上个win98虚拟机. 下载的是经典的Win98.SE.iso 307M. 真是小巧呀,感慨现在的win8.1的3.69G,真是没法比. 原来是没有用过老古董的 ...

  3. SAP成都研究院CEC团队三巨头之一:M君的文章预告

    国人总倾向于把特点或者作用类似的人或物放在一起比较并做出排名,于是就有了许多"某某某三巨头"的称谓. 最举世闻名的莫过于二战三巨头:丘吉尔,罗斯福和斯大林. 还有陪伴咱八零后童年时 ...

  4. shp格式数据发布服务:postGIS + postgresql + geoserver

    主要流程: ①使用postgresql创建数据库 ②下载安装postgis插件 ③在创建的数据库中使用postgis插件,执行下列语句 CREATE EXTENSION postgis; CREATE ...

  5. [转载]AngularJS入门教程01:静态模板

    为了说明angularJS如何增强了标准HTML,我们先将创建一个静态HTML页面模板,然后把这个静态HTML页面模板转换成能动态显示的AngularJS模板. 在本步骤中,我们往HTML页面中添加两 ...

  6. WPF中矢量图标库

    https://www.iconfont.cn/search/index?searchType=icon&q=人员

  7. HTML 5新元素和CSS

    Html5 新元素 多媒体元素 video/audio: 格式例子: 属性: canvas元素 Canvas标签定义图形,用于图形的绘制,使用    js来绘图 拖放drag和drop 拖放是一种常见 ...

  8. iOS进阶面试题

    1. 风格纠错题 修改完的代码: 修改方法有很多种,现给出一种做示例: // .h文件 // http://weibo.com/luohanchenyilong/ // https://github. ...

  9. 常用的ES6语法

    1. let.const 和 block 作用域 let 允许创建块级作用域,ES6 推荐在函数中使用 let 定义变量,而非 var: var a = 2; { let a = 3; console ...

  10. Java是什么?我们为什么要学习Java?

    Dear All: 首先请允许我为大家介绍下什么是Java?,我们为什么要学Java? 1.Java名字的由来 : Java名字的由来,实际上是一个有趣的故事,我们所见到的Java标志,总是一杯热咖啡 ...