基于iOS端的混合項目(美衣品牌會)開發(fā)_第1頁
基于iOS端的混合項目(美衣品牌會)開發(fā)_第2頁
基于iOS端的混合項目(美衣品牌會)開發(fā)_第3頁
基于iOS端的混合項目(美衣品牌會)開發(fā)_第4頁
基于iOS端的混合項目(美衣品牌會)開發(fā)_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

基于iOS端的混合項目(美衣品牌會)開發(fā)

班級:13計算機(jī)科學(xué)與技術(shù)2班姓名:xx

摘要:智能手機(jī)的迅猛發(fā)展使得人類的日常生活與互聯(lián)網(wǎng)的關(guān)系變得越來越緊密,現(xiàn)在人們可以很輕松的在手機(jī)上享受到足不出戶的購物樂趣,如今手機(jī)大致已分為兩大陣營:Android端和iOS端,此次混合軟件的開發(fā)就是基于iOS端進(jìn)行的,而混合軟件可以提高公司產(chǎn)品開發(fā)和更新的速度。

關(guān)鍵字:OC混合應(yīng)用開發(fā)體驗

正文:說到混合軟件,就不得不提原生軟件,那么先來解釋一下什么是混合軟件和原生軟件?它們之間又有什么區(qū)別呢?

原生軟件是指基于智能手機(jī)本地操作系統(tǒng)并且使用原生程序編寫運(yùn)行的移動應(yīng)用程序,開發(fā)原生軟件需要針對不同智能手機(jī)的操作系統(tǒng)來選擇相應(yīng)的軟件開發(fā)編程語言,如iOS端軟件是使用Objective-c語言(蘋果公司在2014年的WWDC上發(fā)布的新開發(fā)語言-Swift也可以用于iOS平臺的應(yīng)用程序開發(fā)),iOS端的混合應(yīng)用程序是指在應(yīng)用程序中是否使用了HTML,javascript或者CSS來創(chuàng)建應(yīng)用中的一些界面,主要通過UIWebView來展示非Objective-c或Swift語言寫的界面。原生軟件有很多優(yōu)勢,因為它是針對不同平臺為用戶提供體驗的,原生軟件的打開速度更快且運(yùn)行更流暢,而相對混合軟件開發(fā)而言,它的開發(fā)時間成本要高,產(chǎn)品的更新要慢,因此在權(quán)衡利弊之后,越來越多的iOS端軟件采用了混合編程語言開發(fā)。

而購物已經(jīng)成為人們?nèi)粘I钪胁豢扇鄙俚囊豁椈顒?,手機(jī)購物軟件的出現(xiàn)讓人們既享受到了購物的樂趣,有解決了出門的各種麻煩。美衣品牌會就在種背景下被開發(fā)出來,軟件的設(shè)計遵循MVC的設(shè)計模式,在工程文件中新建三個文件,分別為model類(模型),view類(視圖),controller類(控制器),model類文件夾下代碼用來存放業(yè)務(wù)邏輯實現(xiàn),view文件夾下代碼主要用來存放展示的界面,controller文件夾下代碼主要用來負(fù)責(zé)響應(yīng)用戶的操作并調(diào)用相對應(yīng)的業(yè)務(wù)邏輯模塊,這樣設(shè)計有利于降低程序的耦合度,便于代碼的復(fù)用和后期的維護(hù)。所以MVC的設(shè)計思想也越來越被廣大的程序開發(fā)者所認(rèn)可。

下面就來介紹下此次軟件,此產(chǎn)品共分為五大模塊,分別為首頁模塊、品牌特賣模塊、1折包郵模塊、分類搜索模塊和我的模塊。設(shè)計思想是每個模塊都是由UIViewController(視圖控制器)進(jìn)行管理,然后再由UITabbarcontroller(標(biāo)簽視圖控制器)進(jìn)行控制各個視圖控制器。首先底部標(biāo)簽視圖欄的主要代碼:-(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)我們調(diào)用UITableVIewController的協(xié)議方法并自定義表它的區(qū)頭內(nèi)容:-(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;

}

品牌特賣部分

網(wǎng)絡(luò)請求是采用ASI第三方框架倒入系統(tǒng)框架用于檢測手機(jī),基于NSURLConnection和NSURLSession封裝

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

{

NSLog(@"品牌特賣模塊的網(wǎng)絡(luò)請求");

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:@"最新上線",@"昨日上線",@"最后瘋搶",@"精致女裝",@"精品男裝",@"鞋包配飾",@"美妝個護(hù)",@"母嬰用品",@"居家生活",@"美食零食",@"數(shù)碼家電",@"文體用品",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:@"女裝",@"男裝",@"鞋品",@"箱包",@"內(nèi)衣",@"美妝個護(hù)",@"配飾",@"中老年",@"母嬰",@"居家",@"美食",@"數(shù)碼家電",@"文體",@"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=^(){

//進(jìn)入系統(tǒng)設(shè)置

MineSetupViewController*setupVC=[[MineSetupViewControlleralloc]init];

setupVC.hidesBottomBarWhenPushed=YES;

[self.navigationControllerpushViewController:setupVCanimated:YES];

};

TaobaoLoginViewController*taboVC=[[TaobaoLoginViewControlleralloc]init];

mineView.dingdanchaxunBlock=^(){

NSLog(@"點(diǎn)擊的是訂單查詢");

taboVC.hidesBottomBarWhenPushed=YES;

taboVC.navigationItem.title=@"查看訂單";

[self.navigationControllerpushViewController:taboVCanimated:YES];

};

mineView.wuliuchaxunBlock=^(){

NSLog(@"點(diǎn)擊的是物流查詢");

taboVC.hidesBottomBarWhenPushed=YES;

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

[self.navigationControllerpushViewController:taboVCanimated:YES];

};

mineView.gouwucheBlock=^(){

NSLog(@"點(diǎn)擊的是購物車查詢");

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:@"推薦給好友",@"清除緩存",@"檢查更新",@"關(guān)于美衣品牌會",nil];

if(cell==nil){

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

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

cell.selectionStyle=UITableViewCellSelectionStyleNone;

}

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

//設(shè)置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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論