设为首页 加入收藏

TOP

iOS 购物—个人中心界面(二)
2014-11-23 21:31:45 来源: 作者: 【 】 浏览:30
Tags:iOS 购物 个人 中心 界面
单"],
@[@"售后服务"],
@[@"设置"]];


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


- (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;
}


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



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


@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



- (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;
}


源码下载地址


------------------------------------------分割线------------------------------------------


具体下载目录在 /2014年资料/8月/25日/iOS 购物—个人中心界面


------------------------------------------分割线------------------------------------------

再次说一下,这些东西是给我们新手看的,或许能够帮到你们,因为我在学习的时候也想有个完整的例子来练一练手。

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


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇iOS 实现QQ界面 下一篇Objective-C 复制对象

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: