// AppDelegate.m
#import "ViewController.h"
#import "LViewController.h"
//啟動(dòng)圖在屏幕顯示時(shí)間
sleep(0);
//判斷是不是第一次打開 如果不是就不顯示
//判斷是否是第一次不是就沒有啟動(dòng)動(dòng)畫
BOOL show=[[NSUserDefaults standardUserDefaults] objectForKey:@"show"];
if(show==NO)
{
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"show"];
LViewController *st=[LViewController new];
self.window.rootViewController=st;
}
else
{
ViewController *vc = [[ViewController alloc] init];
self.window.rootViewController = vc;
}
// ViewController.m
#import "oneViewController.h"
#import "twoViewController.h"
#import "threeViewController.h"
#import "myKuaiViewController.h"
oneViewController *one = [[oneViewController alloc]init];
twoViewController *fenLei = [[twoViewController alloc] init];
threeViewController *gouWuChe = [[threeViewController alloc]init];
myKuaiViewController *myKuaiF = [[myKuaiViewController alloc]init];
UINavigationController *navo = [[UINavigationController alloc]initWithRootViewController:one];
UINavigationController *navf = [[UINavigationController alloc]initWithRootViewController:fenLei];
UINavigationController *navg = [[UINavigationController alloc]initWithRootViewController:gouWuChe];
UINavigationController *navm = [[UINavigationController alloc]initWithRootViewController:myKuaiF];
myKuaiF.tabBarItem.image = [UIImage imageNamed:@"2"];
myKuaiF.title = @"我的快方";
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"首頁(yè)" image:[UIImage imageNamed:@"2.png"] tag:1];
UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"分類" image:[UIImage imageNamed:@"2.png"] tag:1];
UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"購(gòu)物車" image:[UIImage imageNamed:@"2"] tag:1];
//? ? UITabBarItem *item4 = [[UITabBarItem alloc]initWithTitle:@"我的快方" image:[UIImage imageNamed:@"4.png"] tag:1];
navo.tabBarItem = item1;
navf.tabBarItem = item2;
navg.tabBarItem = item3;
//? ? navm.tabBarItem = item4;
self.viewControllers = @[navo,navf,navg,myKuaiF];
//輪播圖// LViewController.m
#import "oneViewController.h"
#import "ViewController.h"
{
//創(chuàng)建滑動(dòng)控件
UIScrollView *theScroll;
//分頁(yè)控件
UIPageControl *thePage;
//創(chuàng)建整型類
NSInteger tegPageTime;
//創(chuàng)建數(shù)組;
NSArray *theArray;
//計(jì)數(shù)器
NSTimer *theTime;
}
//=============================
//獲取屏幕的寬
float width = self.view.frame.size.width;
//獲取屏幕的高
float height = self.view.frame.size.height;
//代替 初始化滾動(dòng)控件
theScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, width, height)];
//獲取屏幕X軸
float X = 0.0;
//一共四張圖片
for (int i = 0; i < 4; i++)
{
//圖片初始化
UIImageView *theImg = [[UIImageView alloc] initWithFrame:CGRectMake(X, 0, width, height)];
//將圖片添加到視圖里
theArray = @[[UIImage imageNamed:@"2"],[UIImage imageNamed:@"2"],[UIImage imageNamed:@"2"],[UIImage imageNamed:@"2"],];
//將圖片與數(shù)組下標(biāo)綁定
theImg.image = theArray[i];
//將圖片添加到滾動(dòng)視圖中
[theScroll addSubview:theImg];
//設(shè)置滾動(dòng)視圖的坐標(biāo) 原代碼
//(width=self.view.frame.size.width+self.view.frame.size.width+self.view.frame.size.width+self.view.frame.size.width,)
X += width;
}
//設(shè)置滾動(dòng)視圖的大小
theScroll.contentSize = CGSizeMake(width * 4, height);
// 設(shè)置滾動(dòng)視圖按頁(yè)滾動(dòng)
theScroll.pagingEnabled = YES;
//滾動(dòng)條隱藏
theScroll.showsHorizontalScrollIndicator = NO;
//設(shè)置代理
theScroll.delegate = self;
//初始化頁(yè)碼
thePage = [[UIPageControl alloc]initWithFrame:CGRectMake(width /2-50, 570, 100, 30)];
//頁(yè)數(shù)
thePage.numberOfPages = 4;
//初始頁(yè)第一頁(yè)
thePage.currentPage = 0;
//清除原來顏色
thePage.backgroundColor = [UIColor clearColor];
//沒動(dòng)原來
thePage.pageIndicatorTintColor = [UIColor greenColor];
//當(dāng)前翻頁(yè)顯示的顏色
thePage.currentPageIndicatorTintColor = [UIColor redColor];
//順序不能亂
[self.view addSubview:theScroll];
[self.view addSubview:thePage];
//記錄當(dāng)前圖片
tegPageTime = thePage.currentPage;
//第一個(gè)幾秒鐘換一下 事件
theTime = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(scroll) userInfo:nil repeats:YES];
/////==================================
//事件
-(void)scroll
{
tegPageTime ++;
if (tegPageTime>=theArray.count)
{
tegPageTime = 0;
}
[theScroll setContentOffset:CGPointMake(tegPageTime*theScroll.frame.size.width, 0) animated:YES];
}
//表示在滑動(dòng)滾動(dòng)視圖的時(shí)候調(diào)用此方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGPoint point=scrollView.contentOffset;//偏移
//獲得所在位置
thePage.currentPage=point.x / scrollView.frame.size.width;
UIButton *theBtn = [[UIButton alloc]init];
if (thePage.currentPage == 3)
{
//停止圖片滾動(dòng)
[theTime setFireDate:[NSDate distantFuture]];
theBtn.frame = CGRectMake(133, 653, 150, 50);
theBtn.backgroundColor = [UIColor orangeColor];
theBtn.layer.cornerRadius = 26;
[theBtn setTitle:@"立即登錄" forState:UIControlStateNormal];
//添加按鈕觸發(fā)事件:必須要用(UIControlEventTouchUpInside)
[theBtn addTarget:self action:@selector(TiaoZh) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:theBtn];
//設(shè)置與用戶無法交互(這樣即可解決按鈕在前面的那頁(yè)中顯示)
//? scrollView.userInteractionEnabled = NO;
}
}
//實(shí)現(xiàn)頁(yè)碼和滾動(dòng)視圖的關(guān)聯(lián)
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollVie
{
thePage.currentPage = theScroll.contentOffset.x / self.view.frame.size.width;
}
//跳轉(zhuǎn)
-(void)TiaoZh
{
ViewController *VC = [[ViewController alloc]init];
[self presentViewController:VC animated:YES completion:nil];
}
// myKuaiViewController.m
{
//cell每一行標(biāo)題
NSArray *_array, *_arrayOne,*_arraytwo,*_arraythree,*_arrayfour,*_arrayfive;
UIButton *buttonmoney,*BtnMy;
//橫排cell 按鈕
UIButton *buttonone,*buttontwo,*buttonthree,*buttonfour;
//按鈕 登錄 優(yōu)惠 積分
UIButton *BtnLoaing,*BtnYou,*BtnJi;
UILabel *lableoneDetext,*labletwoDetext,*lablethreeDetext,*lablefourDetext;
}
@property(nonatomic,strong)UITableView *table;
//=============================
self.title = @"我的快方";
self.view.backgroundColor = [UIColor whiteColor];
_arrayOne= @[@"我的訂單"];
_arraytwo = @[@"地址管理",@"瀏覽記錄",@"查看評(píng)價(jià)"];
_arraythree = @[@"配送范圍",@"推薦有禮",@"積分商城",@"24小時(shí)客服電話"];
_arrayfour = @[@"設(shè)置"];
_table = [[UITableView alloc]initWithFrame:CGRectMake(0, -8, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
_table.delegate = self;
_table.dataSource = self;
//添加視圖
[self.view addSubview:_table];
=========================
//每行cell高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section == 0)
{
if (indexPath.row == 0)
{
return 160;
}
}
else if (indexPath.section == 1)
{
return 53;
}
return 53;
}
//表格每個(gè)分區(qū)
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if(section == 0)
{
//返回的是最上邊的登錄
return 10;
}
else if (section == 1)
{
return 0.01;
}else if (section == 2)
{
return 0.01;
}else if (section == 3)
{
return 0.01;
}
return 21;
}
//一共有幾個(gè)分區(qū)
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
//每個(gè)分區(qū)返回的行數(shù)
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section ==0)
{
return 3;
}else if (section == 1)
{
return _arraytwo.count;
}else if (section == 2)
{
return _arraythree.count;
}else if (section == 3)
{
return _arrayfour.count;
}
return _array.count;
}
//cell里的數(shù)據(jù)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *string = @"string";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:string];
if (!cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:string];
}
//第一個(gè)分區(qū)
if (indexPath.section== 0)
{
if (indexPath.row == 0)
{
UIView *ViewH = [[UIView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, 160)];
ViewH.backgroundColor = [UIColor redColor];
[cell.contentView addSubview:ViewH];
//點(diǎn)擊某一行不變顏色
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//登錄按鈕
BtnLoaing = [UIButton buttonWithType:UIButtonTypeCustom];
BtnLoaing.frame = CGRectMake(15, 55, 130, 50);
[BtnLoaing setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[BtnLoaing addTarget:self action:@selector(Denglu) forControlEvents:UIControlEventTouchUpInside];
[ViewH addSubview:BtnLoaing];
//優(yōu)惠
BtnYou = [UIButton buttonWithType:UIButtonTypeCustom];
BtnYou.frame = CGRectMake(15, 115, 50, 20);
[BtnYou setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[BtnYou addTarget:self action:@selector(YouHui) forControlEvents:UIControlEventTouchUpInside];
[ViewH addSubview:BtnYou];
UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(128, 120, 8,14)];
la.text = @"|";
la.textColor = [UIColor whiteColor];
[ViewH addSubview:la];
//積分
BtnJi = [UIButton buttonWithType:UIButtonTypeCustom];
BtnJi.frame = CGRectMake(195, 115, 50, 20);
[BtnJi setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[BtnJi addTarget:self action:@selector(JiFen) forControlEvents:UIControlEventTouchUpInside];
[ViewH addSubview:BtnJi];
}
//我的訂單
else if (indexPath.row == 1)
{
cell.textLabel.text = @"我的訂單";
}
//橫排各種訂單
else if (indexPath.row == 2)
{
//? ? ? ? ? ? cell.textLabel.text = _arrayOne[indexPath.row];
//? ? ? ? ? ? cell.imageView.image = [UIImage imageNamed:@"分類.png"];
//當(dāng)前訂單
buttonone = [[UIButton alloc]initWithFrame:CGRectMake(-15, 0, self.view.frame.size.width/3, 35)];
[buttonone setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[buttonone setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];? //正常情況
[buttonone addTarget:self action:@selector(current) forControlEvents:UIControlEventTouchUpInside];
buttonone.adjustsImageWhenHighlighted = YES;
lableoneDetext = [[UILabel alloc]initWithFrame:CGRectMake(-15, 35, self.view.frame.size.width/3, 10)];
lableoneDetext.text = @"當(dāng)前訂單";
lableoneDetext.textAlignment =? 1;
lableoneDetext.font = [UIFont systemFontOfSize:10];
[cell addSubview:buttonone];
[cell addSubview:lableoneDetext];
//待付款訂單
buttontwo = [[UIButton alloc]initWithFrame:CGRectMake(85, 0, self.view.frame.size.width/3, 35)];
[buttontwo setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[buttontwo setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];? //正常情況
[buttontwo addTarget:self action:@selector(pending) forControlEvents:UIControlEventTouchUpInside];
buttontwo.adjustsImageWhenHighlighted = YES;
labletwoDetext = [[UILabel alloc]initWithFrame:CGRectMake(85, 35, self.view.frame.size.width/3, 10)];
labletwoDetext.text = @"待付款訂單";
labletwoDetext.textAlignment =? 1;
labletwoDetext.font = [UIFont systemFontOfSize:10];
[cell addSubview:buttontwo];
[cell addSubview:labletwoDetext];
//已完成訂單
buttonthree = [[UIButton alloc]initWithFrame:CGRectMake(185, 0, self.view.frame.size.width/3, 35)];
[buttonthree setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[buttonthree setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];? //正常情況
[buttonthree addTarget:self action:@selector(over) forControlEvents:UIControlEventTouchUpInside];
buttonthree.adjustsImageWhenHighlighted = YES;
lablethreeDetext = [[UILabel alloc]initWithFrame:CGRectMake(185, 35, self.view.frame.size.width/3, 10)];
lablethreeDetext.text = @"已完成訂單";
lablethreeDetext.textAlignment =? 1;
lablethreeDetext.font = [UIFont systemFontOfSize:10];
[cell addSubview:buttonthree];
[cell addSubview:lablethreeDetext];
//待評(píng)價(jià)訂單
buttonfour = [[UIButton alloc]initWithFrame:CGRectMake(275, 0, self.view.frame.size.width/3, 35)];
[buttonfour setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
[buttonfour setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];? //正常情況
[buttonfour addTarget:self action:@selector(evaluate) forControlEvents:UIControlEventTouchUpInside];
buttonfour.adjustsImageWhenHighlighted = YES;
lablefourDetext = [[UILabel alloc]initWithFrame:CGRectMake(275, 35, self.view.frame.size.width/3, 10)];
lablefourDetext.text = @"待評(píng)價(jià)訂單";
lablefourDetext.textAlignment =? 1;
lablefourDetext.font = [UIFont systemFontOfSize:10];
[cell addSubview:buttonfour];
[cell addSubview:lablefourDetext];
}
}
//第二個(gè)分區(qū)
else if (indexPath.section ==1)
{
cell.textLabel.text = _arraytwo[indexPath.row];
if (indexPath.row == 0)
{
cell.imageView.image = [UIImage imageNamed:@"2.png"];
}
else if (indexPath.row == 1)
{
cell.imageView.image = [UIImage imageNamed:@"2.png"];
}
else if (indexPath.row == 2)
{
cell.imageView.image = [UIImage imageNamed:@"2.png"];
}
}
//第三個(gè)分區(qū)
else
if (indexPath.section ==2)
{
cell.textLabel.text = _arraythree[indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"2.png"];
}
else
if (indexPath.section ==3)
{
if (indexPath.row == 0)
{
}
cell.textLabel.text = _arrayfour[indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"2.png"];
}
//點(diǎn)擊每行后的背景顏色
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:236/255.0 green:236/255.0 blue:236/255.0 alpha:0.5];
return cell;
}