基于iOS端的混合项目(美衣品牌会)开发_第1页
基于iOS端的混合项目(美衣品牌会)开发_第2页
基于iOS端的混合项目(美衣品牌会)开发_第3页
基于iOS端的混合项目(美衣品牌会)开发_第4页
基于iOS端的混合项目(美衣品牌会)开发_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于iOS端的混合项目(美衣品牌会)开发

班级:13计算机科学与技术2班姓名:xx

摘要:智能手机的迅猛发展使得人类的日常生活与互联网的关系变得越来越紧密,现在人们可以很轻松的在手机上享受到足不出户的购物乐趣,如今手机大致已分为两大阵营:Android端和iOS端,此次混合软件的开发就是基于iOS端进行的,而混合软件可以提高公司产品开发和更新的速度。

关键字:OC混合应用开发体验

正文:说到混合软件,就不得不提原生软件,那么先来解释一下什么是混合软件和原生软件?它们之间又有什么区别呢?

原生软件是指基于智能手机本地操作系统并且使用原生程序编写运行的移动应用程序,开发原生软件需要针对不同智能手机的操作系统来选择相应的软件开发编程语言,如iOS端软件是使用Objective-c语言(苹果公司在2014年的WWDC上发布的新开发语言-Swift也可以用于iOS平台的应用程序开发),iOS端的混合应用程序是指在应用程序中是否使用了HTML,javascript或者CSS来创建应用中的一些界面,主要通过UIWebView来展示非Objective-c或Swift语言写的界面。原生软件有很多优势,因为它是针对不同平台为用户提供体验的,原生软件的打开速度更快且运行更流畅,而相对混合软件开发而言,它的开发时间成本要高,产品的更新要慢,因此在权衡利弊之后,越来越多的iOS端软件采用了混合编程语言开发。

而购物已经成为人们日常生活中不可缺少的一项活动,手机购物软件的出现让人们既享受到了购物的乐趣,有解决了出门的各种麻烦。美衣品牌会就在种背景下被开发出来,软件的设计遵循MVC的设计模式,在工程文件中新建三个文件,分别为model类(模型),view类(视图),controller类(控制器),model类文件夹下代码用来存放业务逻辑实现,view文件夹下代码主要用来存放展示的界面,controller文件夹下代码主要用来负责响应用户的操作并调用相对应的业务逻辑模块,这样设计有利于降低程序的耦合度,便于代码的复用和后期的维护。所以MVC的设计思想也越来越被广大的程序开发者所认可。

下面就来介绍下此次软件,此产品共分为五大模块,分别为首页模块、品牌特卖模块、1折包邮模块、分类搜索模块和我的模块。设计思想是每个模块都是由UIViewController(视图控制器)进行管理,然后再由UITabbarcontroller(标签视图控制器)进行控制各个视图控制器。首先底部标签视图栏的主要代码:-(void)createCustomTabBar

{

HomeViewController*homeVC=[[HomeViewControlleralloc]init];

homeVC.navigationItem.title=@"美衣品牌会";

homeVC.tabBarItem=[selfcreateTabBarItemWithTitle:@"首页"unselectImage:@"guide_home_nm.png"selectImage:@"guide_home_on.png"];

UINavigationController*homeNav=[[UINavigationControlleralloc]initWithRootViewController:homeVC];

TeMaiViewController*teMaiVC=[[TeMaiViewControlleralloc]init];

teMaiVC.tabBarItem=[selfcreateTabBarItemWithTitle:@"品牌特卖"unselectImage:@"guide_sale_nm.png"selectImage:@"guide_sale_on.png"];

UINavigationController*teMaiNav=[[UINavigationControlleralloc]initWithRootViewController:teMaiVC];

BaoYouViewController*baoYouVC=[[BaoYouViewControlleralloc]init];

baoYouVC.navigationItem.title=@"1折包邮";

baoYouVC.tabBarItem=[selfcreateTabBarItemWithTitle:@"1折包邮"unselectImage:@"guide_nine_nm.png"selectImage:@"guide_nine_on.png"];

UINavigationController*baoYouNav=[[UINavigationControlleralloc]initWithRootViewController:baoYouVC];

ClassViewController*classVC=[[ClassViewControlleralloc]init];

classVC.tabBarItem=[selfcreateTabBarItemWithTitle:@"分类搜索"unselectImage:@"guide_cart_nm.png"selectImage:@"guide_cart_on.png"];

UINavigationController*classNav=[[UINavigationControlleralloc]initWithRootViewController:classVC];

MineViewController*mineVC=[[MineViewControlleralloc]init];

mineVC.navigationItem.title=@"我的";

mineVC.tabBarItem=[selfcreateTabBarItemWithTitle:@"我的"unselectImage:@"guide_account_nm.png"selectImage:@"guide_account_on.png"];

UINavigationController*mineNav=[[UINavigationControlleralloc]initWithRootViewController:mineVC];

self.viewControllers=@[homeNav,teMaiNav,baoYouNav,classNav,mineNav];

}

首页部分整体是一张表(UITableView)我们调用UITableVIewController的协议方法并自定义表它的区头内容:-(UIView*)tableView:(UITableView*)tableViewviewForHeaderInSection:(NSInteger)section

{

UIView*bgview=[[UIViewalloc]initWithFrame:CGRectMake(0,0,320,250+10)];

bgview.backgroundColor=[UIColorgreenColor];

[self.viewaddSubview:bgview];

_homeScrollView=[[UIScrollViewalloc]init];

_homeScrollView.tag=500;

_homeScrollView.frame=CGRectMake(0,0,320,150);

_homeScrollView.pagingEnabled=YES;

_homeScrollView.bounces=NO;

_homeScrollView.contentOffset=CGPointMake(320,0);

_homeScrollView.contentSize=CGSizeMake(320*6,150);

_homeScrollView.delegate=self;

[bgviewaddSubview:_homeScrollView];

/*

//for(inta=0;a<IMAGECOUNT;a++){

//UIImageView*imageView=[[UIImageViewalloc]initWithFrame:CGRectMake(320*a,0,320,150)];

//HeaderModel*headerModel=[_receiveHeaderModel.adListobjectAtIndex:a];

////NSLog(@"照片的URL%@",headerModel.imgUrl);

//

//[imageViewsd_setImageWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@",headerModel.imgUrl]]placeholderImage:[UIImageimageNamed:@"default_img.png"]];

//[_homeScrollViewaddSubview:imageView];

//}

*/

for(inta=0;a<6;a++){

UIImageView*imageView=[[UIImageViewalloc]initWithFrame:CGRectMake(320*a,0,320,150)];

HeaderModel*headerModel=nil;

switch(a){

case0:{

headerModel=[_receiveHeaderModel.adListobjectAtIndex:3];

}

break;

case1:{

headerModel=[_receiveHeaderModel.adListobjectAtIndex:0];

}

break;

case2:{

headerModel=[_receiveHeaderModel.adListobjectAtIndex:1];

}

break;

case3:{

headerModel=[_receiveHeaderModel.adListobjectAtIndex:2];

}

break;

case4:{

headerModel=[_receiveHeaderModel.adListobjectAtIndex:3];

}

break;

case5:{

headerModel=[_receiveHeaderModel.adListobjectAtIndex:0];

}

break;

default:

break;

}

[imageViewsd_setImageWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@",headerModel.imgUrl]]placeholderImage:[UIImageimageNamed:@"default_img.png"]];

[_homeScrollViewaddSubview:imageView];

}

_pageControl=[[UIPageControlalloc]initWithFrame:CGRectMake(0,130,150,20)];

_pageControl.numberOfPages=4;

_pageControl.pageIndicatorTintColor=[UIColorgrayColor];

_pageControl.currentPageIndicatorTintColor=[UIColorredColor];

[_pageControladdTarget:selfaction:@selector(pageChange:)forControlEvents:UIControlEventValueChanged];

[bgviewaddSubview:_pageControl];

使用UIcollectionview

UICollectionViewFlowLayout*layout=[[UICollectionViewFlowLayoutalloc]init];

layout.itemSize=CGSizeMake(50,50);

layout.minimumLineSpacing=2;

layout.sectionInset=UIEdgeInsetsMake(0,20,0,20);

UICollectionView*collectionView=[[UICollectionViewalloc]initWithFrame:CGRectMake(0,150,320,100+10)collectionViewLayout:layout];

collectionView.backgroundColor=[UIColorwhiteColor];

collectionView.bounces=NO;

collectionView.delegate=self;

collectionView.dataSource=self;

collectionView.scrollEnabled=NO;

[collectionViewregisterClass:[HomeHeaderCellclass]forCellWithReuseIdentifier:@"collectionViewCell"];

[bgviewaddSubview:collectionView];

returnbgview;

}

品牌特卖部分

网络请求是采用ASI第三方框架倒入系统框架用于检测手机,基于NSURLConnection和NSURLSession封装

+(void)teMaiRequestWithBclass:(NSInteger)classandCPage:(NSInteger)pagecompletion:(void(^)(id))teMaiBlock

{

NSLog(@"品牌特卖模块的网络请求");

NSURL*url=[NSURLURLWithString:[NSStringstringWithFormat:@"/apptools/brandsale.aspx"]];

__weakASIFormDataRequest*request=[ASIFormDataRequestrequestWithURL:url];

[requestsetPostValue:@"brandlist"forKey:@"act"];

[requestsetPostValue:[NSNumbernumberWithInteger:class]forKey:@"bclass"];

[requestsetPostValue:[NSNumbernumberWithInteger:page]forKey:@"cpage"];

[requestsetCompletionBlock:^{

NSLog(@"品牌特卖请成功");

//NSLog(@"+++++%@",request.responseString);

//NSLog(@"~~~~~~%@",[NSJSONSerializationJSONObjectWithData:request.responseDataoptions:NSJSONReadingMutableContainerserror:nil]);

NSDictionary*objectDict=[NSJSONSerializationJSONObjectWithData:request.responseDataoptions:NSJSONReadingMutableContainerserror:nil];

TeMaiModel*model=[[TeMaiModelalloc]initWithObjectDictionary:objectDict];

teMaiBlock(model);

//NSLog(@"model.rowsArray.count%d",model.rowsArray.count);

}];

[requestsetFailedBlock:^{

NSLog(@"品牌特卖请求失败的原因%@",request.error);

ALERTSHOW;

}];

[requeststartAsynchronous];

}

顶部的滚动条

-(void)createScrollView

{

self.automaticallyAdjustsScrollViewInsets=NO;

NSArray*titleArray=[[NSArrayalloc]initWithObjects:@"最新上线",@"昨日上线",@"最后疯抢",@"精致女装",@"精品男装",@"鞋包配饰",@"美妆个护",@"母婴用品",@"居家生活",@"美食零食",@"数码家电",@"文体用品",nil];

UIScrollView*titleScrollView=[[UIScrollViewalloc]initWithFrame:CGRectMake(0,20,320,44)];

titleScrollView.backgroundColor=[UIColorgrayColor];

titleScrollView.contentSize=CGSizeMake(80*12,44);

titleScrollView.panGestureRecognizer.delaysTouchesBegan=YES;

titleScrollView.showsHorizontalScrollIndicator=NO;

for(inta=0;a<12;a++){

UIButton*button=[UIButtonbuttonWithType:UIButtonTypeCustom];

button.frame=CGRectMake(80*a,0,80,42);

button.tag=a;

[buttonsetTitle:[titleArrayobjectAtIndex:a]forState:UIControlStateNormal];

[buttonsetTitleColor:[UIColorblackColor]forState:UIControlStateNormal];

if(a==0){

[buttonsetTitleColor:[UIColorredColor]forState:UIControlStateNormal];

_recordButton=button;

UILabel*label1=[[UILabelalloc]initWithFrame:CGRectMake(0,39,80,3)];

label1.backgroundColor=[UIColorredColor];

[buttonaddSubview:label1];

_recordLabel=label1;

}

button.titleLabel.font=[UIFontsystemFontOfSize:15];

button.backgroundColor=[UIColorwhiteColor];

[buttonaddTarget:selfaction:@selector(clickButton:)forControlEvents:UIControlEventTouchUpInside];

[titleScrollViewaddSubview:button];

}

titleScrollView.bounces=NO;

[self.viewaddSubview:titleScrollView];

}

商品的展示

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

{

TeMaiCustomTableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:@"cell"forIndexPath:indexPath];

cell.backgroundColor=[UIColorlightGrayColor];

cell.selectionStyle=UITableViewCellSelectionStyleNone;

//

//TeMaiModelTwo*twoModel=[_receiveModel.rowsArrayobjectAtIndex:indexPath.row];

TeMaiModelTwo*twoModel=[_receiveModelArrayobjectAtIndex:indexPath.row];

//品牌图片

[cell.titleImageViewsd_setImageWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@%@",IMAGEURL,twoModel.imgUrlSml]]placeholderImage:[UIImageimageNamed:@"fire"]];

//品牌名

cell.titleLabel.text=twoM;

//折扣起步

floatdiscount=[twoModel.disCountfloatValue];

cell.discountLabel.text=[NSStringstringWithFormat:@"%0.2f折起",discount];

//剩余几天

NSDateFormatter*dateFormatter=[[NSDateFormatteralloc]init];

dateFormatter.dateFormat=@"yyyy-MM-ddHH:mm:ss";

NSString*endDateStr=twoModel.endDataStr;

NSDate*endDate=[dateFormatterdateFromString:endDateStr];

NSDate*nowDate=[NSDatedate];

NSCalendar*calendar=[NSCalendarcurrentCalendar];

NSCalendarUnitunit=NSCalendarUnitDay|NSCalendarUnitHour;

NSDateComponents*com=[calendarcomponents:unitfromDate:nowDatetoDate:endDateoptions:0];

if(com.day==0){

cell.dataLabel.text=[NSStringstringWithFormat:@"剩%d小时",com.hour];

}else{

cell.dataLabel.text=[NSStringstringWithFormat:@"剩%d天",com.day];

}

//大图图片

TeMaiProductInfoModel*infoModel0=twoMductInfo[0];

[cell.bigImageViewsd_setImageWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@%@",IMAGEURL,infoMductImg]]placeholderImage:[UIImageimageNamed:@"default_img.png"]];

cell.bigPriceLabel.text=[NSStringstringWithFormat:@"¥%@",infoModel0.NewPrice];

floatbigDiscount=[infoModel0.disCountfloatValue];

cell.bigDiscountLabel.text=[NSStringstringWithFormat:@"%.2f折",bigDiscount];

//上小图

TeMaiProductInfoModel*infoModel1=twoMductInfo[1];

[cell.smallUpImageViewsd_setImageWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@%@",IMAGEURL,infoMductImg]]placeholderImage:[UIImageimageNamed:@"defaul_bannerimg.png"]];

cell.sUpPriceLabel.text=[NSStringstringWithFormat:@"¥%@",infoModel1.NewPrice];

floatsmallUpDiscount=[infoModel1.disCountfloatValue];

cell.sUpDiscountLabel.text=[NSStringstringWithFormat:@"%.2f折",smallUpDiscount];

//下小图

TeMaiProductInfoModel*infoModel2=twoMductInfo[2];

[cell.smallDownImageViewsd_setImageWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@%@",IMAGEURL,infoMductImg]]placeholderImage:[UIImageimageNamed:@"defaul_bannerimg.png"]];

cell.sDownPriceLabel.text=[NSStringstringWithFormat:@"¥%@",infoModel2.NewPrice];

floatsmallDownDiscount=[infoModel2.disCountfloatValue];

cell.sDownDiscountLabel.text=[NSStringstringWithFormat:@"%.2f折",smallDownDiscount];

returncell;

}

分类搜索

-(UICollectionViewCell*)collectionView:(UICollectionView*)collectionViewcellForItemAtIndexPath:(NSIndexPath*)indexPath

{

CustomClassCell*cell=[collectionViewdequeueReusableCellWithReuseIdentifier:@"classCell"forIndexPath:indexPath];

NSArray*imageNameArray=[[NSArrayalloc]initWithObjects:@"fushi.png",@"nanzhuang.png",@"nvxie.png",@"xiangbao.png",@"nieyi.png",@"huazhuangpin.png",@"peishi.png",@"oldman.png",@"muying.png",@"jujia.png",@"meishi.png",@"shuma.png",@"wenti.png",@"jkj.png",@"newsort.png",nil];

NSArray*labelNameArray=[[NSArrayalloc]initWithObjects:@"女装",@"男装",@"鞋品",@"箱包",@"内衣",@"美妆个护",@"配饰",@"中老年",@"母婴",@"居家",@"美食",@"数码家电",@"文体",@"9.9包邮",@"今日更新",nil];

cell.classImageView.image=[UIImageimageNamed:[imageNameArrayobjectAtIndex:indexPath.row]];

cell.classLabel.text=[labelNameArrayobjectAtIndex:indexPath.row];

returncell;

}

一折包邮模块与品牌特卖部分类似不做介绍了

我的部分

-(void)viewDidLoad{

[superviewDidLoad];

[self.navigationController.navigationBarsetBarTintColor:[[UIColoralloc]initWithRed:248/256.0green:78/256.0blue:78/256.0alpha:1.0]];

self.view.backgroundColor=[UIColorwhiteColor];

MineCustomView*mineView=[[MineCustomViewalloc]initWithFrame:CGRectMake(0,64,320,100)];

mineView.setupBlock=^(){

//进入系统设置

MineSetupViewController*setupVC=[[MineSetupViewControlleralloc]init];

setupVC.hidesBottomBarWhenPushed=YES;

[self.navigationControllerpushViewController:setupVCanimated:YES];

};

TaobaoLoginViewController*taboVC=[[TaobaoLoginViewControlleralloc]init];

mineView.dingdanchaxunBlock=^(){

NSLog(@"点击的是订单查询");

taboVC.hidesBottomBarWhenPushed=YES;

taboVC.navigationItem.title=@"查看订单";

[self.navigationControllerpushViewController:taboVCanimated:YES];

};

mineView.wuliuchaxunBlock=^(){

NSLog(@"点击的是物流查询");

taboVC.hidesBottomBarWhenPushed=YES;

taboVC.navigationItem.title=@"查看物流";

[self.navigationControllerpushViewController:taboVCanimated:YES];

};

mineView.gouwucheBlock=^(){

NSLog(@"点击的是购物车查询");

taboVC.hidesBottomBarWhenPushed=YES;

taboVC.navigationItem.title=@"查看购物车";

[self.navigationControllerpushViewController:taboVCanimated:YES];

};

[self.viewaddSubview:mineView];

}

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

{

UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:@"cell"];

NSArray*imageArray=[NSArrayarrayWithObjects:@"usericon_collect.png",@"usericon_clear.png",@"usericon_update.png",@"usericon_aboutus.png",nil];

NSArray*textArray=[NSArrayarrayWithObjects:@"推荐给好友",@"清除缓存",@"检查更新",@"关于美衣品牌会",nil];

if(cell==nil){

cell=[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleValue1reuseIdentifier:@"cell"];

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

cell.selectionStyle=UITableViewCellSelectionStyleNone;

}

UIImage*icon=[UIImageimageNamed:[imageArrayobjectAtIndex:indexPath.row]];

//设置tableviewcell上图片的大小

CGSizeitemSize=CGSizeMake(40,40);

UIGraphicsBeginImageContextWithOptions(itemSize,NO,0.0);

CGRectimageRect=CGRectMake(0,0,itemSize.width,itemSize.height);

[icondrawInRect:imageRect];

cell.imageView.image=UIGraphicsGetImageFromCurrentI

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论