上一个QQ界面真实无心插柳,想不到一个新手的普通界面可以上首页推荐,在这谢谢那些csdn工作者对新手的支持,谢谢soledadzz  的特别推荐;

以下这个界面也是师傅锻炼我的题目主要是让我熟悉table的使用;我想尽量的去用mvc,尽量的去实现界面与数据的分离,可是一个水平没有达到,不知道这种界面算不算一个真正的分离,还差多少,假设您看出了问题,请留一下言,帮忙扶一把,谢谢!

文件原代码究竟部的链接下载,谢谢,须要一分来赚点外块,假设没有积分能够留言,或者留下QQ我发给大家。

因为本人ps技术的原因,没可以将底部的四张小图片弄出来,致使底部的tabBar 没有图片,大家可以自己加上。

先来说下文件:

由于近期看可代码规范的一些东西,刚開始用,我想名字什么的尽量的去做到,看到名字就知道是干嘛的。

在personalcentreTable文件里放得是 界面中间的table和cell 以下personalcentreHeadview 是界面头部也就是 头像,蓝色背景那部分

personalcentreview 就是整个的界面部分了;

其它地方没有必要介绍了;

先在Appdelegate中实现了tabBar

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
_window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
UIViewController *vc1 = [[UIViewController alloc]init];
vc1.view.backgroundColor = [UIColor redColor];
vc1.title = @"首页";
UIViewController *vc2 = [[UIViewController alloc]init];
vc2.view.backgroundColor = [UIColor grayColor];
vc2.title = @"商家";
UIViewController *vc3 = [[UIViewController alloc]init];
vc3.view.backgroundColor = [UIColor greenColor];
vc3.title = @"购物车";
ViewController *vc4 = [[ViewController alloc]init];
vc4.title = @"个人中心";
NSArray *arrayVC = @[vc1,vc2,vc3,vc4];
self.tabBarC = [[UITabBarController alloc]init];
self.tabBarC.viewControllers = arrayVC;
_window.rootViewController = self.tabBarC;
[_window makeKeyAndVisible];
return YES;
}

构造数据:

NSDictionary *dictionary = @{@"personal_protrait":@"icon.png",
@"personal_name":@"雪松",
@"personal_integral":@"200",
@"personal_welfare":@"59",
@"personal_table":@{@"待付款订单":@"10",
@"待发货订单":@"5",
@"已发货订单":@"4"}
};

先来看下cell吧

@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *numberLabel;
@property (nonatomic,strong) UIImageView *rightImageView;

一个名字 ,一个数字,一个图标 能够对比图一看就明确;

- (id)initWithName:(NSString *)name number:(NSString *)number rightImage:(UIImage *)image
{
self = [super init];
if (self) {
//设置文字
_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 100, 20)];
_nameLabel.text =name;
[self addSubview:_nameLabel]; //设置标识数字
_numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(250, 10, 30, 20)];
_numberLabel.text = number;
_numberLabel.textAlignment = 1;
_numberLabel.textColor = [UIColor redColor];
[self addSubview:_numberLabel]; //设置右边图片
_rightImageView = [[UIImageView alloc]initWithFrame:CGRectMake(290, 10, 15, 20)];
_rightImageView.image = image;
[self addSubview:_rightImageView]; }
return self;
}

接下来是table了

@interface PersonalCentreTable : UITableView<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,copy) NSDictionary *dataDictionary;   //传递的数据

- (id)initWithDictionary:(NSDictionary *)dictionary;
@end

在实现table时我想 有4个section 并且行数也不一样,每行的内容也不一样,这样在

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

怎么写啊,要一个一个if的去推断是哪个section 然后推断是哪一行吗?这样费劲了,于是我想到了数组。一个老手应该自然会想到,可是作为新手能用还是蛮高兴的;

tableArray = @[@[@"待付款订单",
@"待发货订单",
@"已发货订单"],
@[@"已完毕订单"],
@[@"售后服务"],
@[@"设置"]];

这个数组然后与以下的代码结合起来就简洁多了

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PersonalCentreTableCell *cell ; if (indexPath.section == 0) {
NSString *name = [(NSArray *)[tableArray objectAtIndex:indexPath.section]
objectAtIndex:indexPath.row];
cell = [[PersonalCentreTableCell alloc]
initWithName:name
number:[_dataDictionary objectForKey:name]
rightImage:[UIImage imageNamed:@"rightImage.png"]];
}
else {
cell = [[PersonalCentreTableCell alloc]
initWithName:[(NSArray *)[tableArray objectAtIndex:indexPath.section]
objectAtIndex:indexPath.row]
number:@""
rightImage:[UIImage imageNamed:@"rightImage.png"]];
}
return cell;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return section == 0? 3:1;
//return ((NSArray *)[_dataArray objectAtIndex:section]).count;
}

这里我想说的是我们应该多去用 ?: 少去写if,应该先考虑?: 这样我们的代码更加整洁;

说完这些小部分,那让我们来看看整个部分吧personalcentreview;

<span style="font-size:12px;">@interface PersonalCentreView : UIView

@property (nonatomic,strong) UILabel *titleLabel;//标题
@property (nonatomic,strong) PersonalCentreHeadView *personalCentreHeadView;//头部 个人头像部分
@property (nonatomic,strong) PersonalCentreTable *personalCentreTable;//表格部分
@property (nonatomic,copy) NSDictionary *dataDictionary;//数据 - (id)initWithDictionary:(NSDictionary *)dictionary;
@end</span>
- (id)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_dataDictionary = dictionary; //self.frame = CGRectMake(0, 0, 320, 480); self.backgroundColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1]; // 设置标题
_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, 280, 20)];
_titleLabel.text = @"个人中心";
_titleLabel.textAlignment = 1;//居中
// _titleLabel.textColor = [UIColor whiteColor];
[self addSubview:_titleLabel]; //设置头像部分
_personalCentreHeadView = [[PersonalCentreHeadView alloc]initWithPortrait:[dictionary objectForKey:@"personal_image"]
Name:[dictionary objectForKey:@"personal_name"]
Integral:[dictionary objectForKey: @"personal_integral"]
Welfare:[dictionary objectForKey:@"personal_welfare"]];
[self addSubview:_personalCentreHeadView]; //设置表格
_personalCentreTable = [[PersonalCentreTable alloc]initWithDictionary:[dictionary objectForKey:@"personal_table"]];
[self addSubview:_personalCentreTable]; }
return self;
}

源代码下载地址:http://download.csdn.net/detail/u010123208/7805865

再次说一下,这些东西是给我们新手看的,也许可以帮到你们,由于我在学习的时候也想有个完整的样例来练一练手。

大神们,建议意见,我们希望你们能留下。“一个简单的界面,也好意思说。。。”这种话我们不希望看到,我就不相信,一年两年之后你还会比我们强。

iOS 购物—个人中心界面的更多相关文章

  1. IOS Notification 通知中心

    1.     通知中心概述 通知中心实际上是在程序内部提供了消息广播的一种机制.通知中心不能在进程间进行通信.实际上就是一个二传手,把接收到的消息,根据内部的一个消息转发表,来将消息转发给需要的对象. ...

  2. Xamarin iOS教程之编辑界面编写代码

    Xamarin iOS教程之编辑界面编写代码 Xamarin iOS的Interface Builder Interface Builder被称为编辑界面.它是一个虚拟的图形化设计工具,用来为iOS应 ...

  3. iOS Swift WisdomHUD 提示界面框架

    iOS Swift WisdomHUD 提示界面框架  Framework Use profile(应用简介) 一:WisdomHUD简介 今天给大家介绍一款iOS的界面显示器:WisdomHUD,W ...

  4. IOS中通知中心(NSNotificationCenter)

    摘要 NSNotification是IOS中一个调度消息通知的类,采用单例模式设计,在程序中实现传值.回调等地方应用很广.   IOS中通知中心NSNotificationCenter应用总结 一.了 ...

  5. 安卓端调用h5界面js方法和ios端调用h5界面js方法

      备注:本人为h5开发人员,不懂安卓和ios,这是开发小伙伴对接联调的主代码. 1.iOS端调用h5界面js方法:     2.安卓端调用h5界面js方法: @Override    protect ...

  6. iOS 跳转系统设置界面

    iOS 跳转系统设置界面   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Pri ...

  7. iOS 8 Auto Layout界面自动布局系列5-自身内容尺寸约束、修改约束、布局动画

    首先感谢众多网友的支持,最近我实在是事情太多,所以没有写太多.不过看到大家的反馈和评价,我还是要坚持挤出时间给大家分享我的经验.如果你对我写的东西有任何建议.意见或者疑问,请到我的CSDN博客留言: ...

  8. IOS与Android APP界面设计规范要点

    IOS篇 一.尺寸及分辨率 iPhone界面尺寸:320*480.640*960.640*1136 iPhone6:4.7英寸(1334×750),iPhone6 Plus:5.5英寸(1920×10 ...

  9. iOS 8 Auto Layout界面自动布局系列2-使用Xcode的Interface Builder添加布局约束

    http://blog.csdn.net/pucker/article/details/41843511 上一篇文章<iOS 8界面自动布局系列-1>简要介绍了iOS界面布局方式的前世今生 ...

随机推荐

  1. meminfo,df,

    yx100:root@yxRouter:/# cat /proc/meminfoMemTotal:         126584 kBMemFree:          103156 kBBuffer ...

  2. ibatis新手入门

    ibatis 是什么 iBATIS是以SQL为中心的持久化层框架. 能支持懒载入.关联查询.继承等特性. iBATIS不同于一般的OR映射框架. OR映射框架,将数据库表.字段等映射到类.属性,那是一 ...

  3. 在ListView中实现排序

    此处介绍的情境是: (1)使用table布局ListView. (2)ListView的数据源是List<T>. (3)排序字段2个(帖子的回复次数和浏览次数),都是int类型. 基本思路 ...

  4. 与众不同 windows phone (25) - Input(输入)之捕获 UIElement 之外的触控操作, Silverlight 方式捕获手势操作, XNA 方式捕获手势操作, 多点触控

    原文:与众不同 windows phone (25) - Input(输入)之捕获 UIElement 之外的触控操作, Silverlight 方式捕获手势操作, XNA 方式捕获手势操作, 多点触 ...

  5. 参数传递方法(Delphi1.0与win16API使用pascal方法,即从左到右)

    参数传递方法李维的InsideVCL<第一章>中提到Windows定义的回调函数typedef LRESULT (CALLBACK*WNDPROC)(HWND,UNIT,WPARAM,LP ...

  6. ie浏览器提交参数和其它浏览器的区别

    场景描述: 用户注册模块(ajax提交方式,post方法),在url后追加了一个参数,如:url+‘btnvalue=中文参数’,如此在非ie浏览器注册时,功能完好,但在ie下注册不成功.调式后发现在 ...

  7. Java程序猿的JavaScript学习笔记(3——this/call/apply)

    计划按例如以下顺序完毕这篇笔记: Java程序猿的JavaScript学习笔记(1--理念) Java程序猿的JavaScript学习笔记(2--属性复制和继承) Java程序猿的JavaScript ...

  8. Android APP代码拨打电话、打开手机分享功能等隐式意图

    Android APP拨打电话: Intent intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+110)); start ...

  9. (1)cocos2d-x-2.2.4搭建windows开发环境

    Cocos2d-x-2.2.4搭建windows环境 软件需求 Windows系统(windows7或之后的系统): cocos2d-x-2.2.4压缩包. python安装包(推荐使用2.7.3版本 ...

  10. C++--allocator类的使用

    C++为我们提供了安全的内存空间申请方式与释放方式,可是new与delete表达式却是把空间的分配回收与对象的构建销毁紧紧的关联在一起.实际上,作为与C语言兼容的语言,C++也为我们提供了更加底层的内 ...