ViewController.h
#import
@interfaceViewController :UITabBarController
@end
ViewController.m
#import "ViewController.h"
#import "oneViewController.h"
#import "twoViewController.h"
#import "threeViewController.h"
#import "fourViewController.h"
#import "fiveViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
oneViewController *one = [oneViewController new];
UINavigationController *oneNav = [[UINavigationController alloc]initWithRootViewController:one];
oneNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"今日特卖" image:[UIImage imageNamed:@"aa"] selectedImage:[UIImage imageNamed:@"aa"]];
twoViewController *two = [twoViewController new];
UINavigationController *twoNav = [[UINavigationController alloc]initWithRootViewController:two];
twoNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"社区" image:[UIImage imageNamed:@"bb"] selectedImage:[UIImage imageNamed:@"bb"]];
threeViewController *three = [threeViewController new];
UINavigationController *threeNav = [[UINavigationController alloc]initWithRootViewController:three];
threeNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"升级权益" image:[UIImage imageNamed:@"cc"] selectedImage:[UIImage imageNamed:@"cc"]];
fourViewController *four = [fourViewController new];
UINavigationController *fourNav = [[UINavigationController alloc]initWithRootViewController:four];
fourNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"购物车" image:[UIImage imageNamed:@"dd"] selectedImage:[UIImage imageNamed:@"dd"]];
fiveViewController *five = [fiveViewController new];
UINavigationController *fiveNav = [[UINavigationController alloc]initWithRootViewController:five];
fiveNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"个人中心" image:[UIImage imageNamed:@"ee"] selectedImage:[UIImage imageNamed:@"ee"]];
self.viewControllers= @[oneNav,twoNav,threeNav,fourNav,fiveNav];
}
@end
one.m
#import "oneViewController.h"
@interface oneViewController ()<UITableViewDelegate,UITableViewDataSource>
{
UITableView *tbv;
UIScrollView *scro;
UIPageControl *pag;
NSTimer*timer;
intk;
}
@end
@implementationoneViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"aa"] style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bb"] style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.title = @"贝店";
tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
tbv.dataSource = self;
tbv.delegate = self;
[self.view addSubview:tbv];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView{
return1;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
return1;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"2"];
if(!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"2"];
}
tbv.rowHeight= 50;
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 0, 70, 50)];
label.text=@"今日特卖";
label.textColor = [UIColor redColor];
[celladdSubview:label];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(90, 0, 40, 50)];
label2.text=@"居家";
[celladdSubview:label2];
UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(145, 0, 40, 50)];
label3.text=@"居家";
[celladdSubview:label3];
UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(200, 0, 40, 50)];
label4.text=@"居家";
[celladdSubview:label4];
UILabel*label5 = [[UILabelalloc]initWithFrame:CGRectMake(250 , 0, 40, 50)];
label5.text=@"居家";
[celladdSubview:label5];
UILabel*label6 = [[UILabelalloc]initWithFrame:CGRectMake(300 , 0, 40, 50)];
label6.text=@"居家";
[celladdSubview:label6];
// 初始化滚动式图
scro = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, 200)];
// 设置滚动范围
scro.contentSize = CGSizeMake(3 * self.view.frame.size.width, 0);
// 禁用弹簧效果
scro.bounces=NO;
// 禁用水平滚动
scro.showsHorizontalScrollIndicator = NO;
// 设置整页滚动
scro.pagingEnabled = YES;
// 设置代理
scro.delegate=self;
// 设置滚动图片
for(inti = 0 ; i < 3 ; i++){
// 设置图片数组
NSArray*arr = @[@"1",@"2",@"3"];
UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(i * self.view.frame.size.width, 0, self.view.frame.size.width, 200)];
// 加载图片
imgV.image= [UIImageimageNamed:arr[i]];
// 添加到滚动视图中
[scroaddSubview:imgV];
}
// 添加到cell中
[celladdSubview:scro];
// 设置豆豆
pag = [[UIPageControl alloc]initWithFrame:CGRectMake(90, 95, 150, 25)];
// 设置豆豆的数量
pag.numberOfPages = 3;
// 设置豆豆的颜色
pag.currentPageIndicatorTintColor = [UIColor orangeColor];
pag.pageIndicatorTintColor = [UIColor whiteColor];
// 添加到单元格中
[celladdSubview:pag];
// 创建定时器
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(aaa) userInfo:nil repeats:YES];
returncell;
}
// 滚动视图
- (void)scrollViewDidScroll:(UIScrollView*)scrollView{
// NSLog(@"%lf",scro.contentOffset.x);
pag.currentPage = scro.contentOffset.x/self.view.frame.size.width;
}
// 定时器
-(void)aaa{
[scro setContentOffset:CGPointMake(k * self.view.frame.size.width, 0)];
k++;
if(k> 2){
k= 0;
}
}
@end
two.m
#import "fiveViewController.h"
#import "SZViewController.h"
@interface fiveViewController ()<UITableViewDelegate,UITableViewDataSource>
{
UITableView *tbv;
}
@end
@implementationfiveViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"aa"] style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bb"] style:UIBarButtonItemStylePlain target:self action:@selector(click)];
tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
tbv.dataSource = self;
tbv.delegate = self;
[self.view addSubview:tbv];
}
- (void)click{
[self.navigationController pushViewController:[SZViewController new] animated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView{
return5;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
if(section==0) {
return1;
}elseif(section==1){
return1;
}elseif(section==2){
return1;
}elseif(section==3){
return1;
}else{
return1;
}
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"2"];
if(!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"2"];
}
if(indexPath.section==0) {
tbv.rowHeight= 150;
cell.backgroundColor = [UIColor redColor];
UIView * uiv = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 150)];
UIImageView * ima = [[UIImageView alloc]initWithFrame:CGRectMake(20, 40, 100, 100)];
ima.image = [UIImage imageNamed:@"1"];
ima.layer.masksToBounds= YES;
ima.layer.cornerRadius= 50;
[uivaddSubview:ima];
[celladdSubview:uiv];
UILabel*label = [[UILabelalloc]initWithFrame:CGRectMake(130, 90, 150, 50)];
label.text=@"谎言";
[celladdSubview:label];
UILabel*label2 = [[UILabelalloc]initWithFrame:CGRectMake(280, 90, 150, 50)];
label2.text=@"成长值2>";
[celladdSubview:label2];
}elseif(indexPath.section==1){
tbv.rowHeight= 150;
UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 150, 50)];
label3.text=@"我的订单";
[celladdSubview:label3];
UILabel*label4 = [[UILabelalloc]initWithFrame:CGRectMake(250, 0, 200, 50)];
label4.text=@"查看全部订单>";
[celladdSubview:label4];
UIImageView * ima5 = [[UIImageView alloc]initWithFrame:CGRectMake(28, 60, 50, 50)];
ima5.image = [UIImage imageNamed:@"11"];
ima5.layer.masksToBounds = YES;
ima5.layer.cornerRadius= 25;
[celladdSubview: ima5];
UILabel * lab5 = [[UILabel alloc]initWithFrame:CGRectMake(30, 110, 60, 20)];
lab5.text=@"当前订单";
lab5.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab5];
UIImageView * ima6 = [[UIImageView alloc]initWithFrame:CGRectMake(128, 60, 50, 50)];
ima6.image = [UIImage imageNamed:@"11"];
ima6.layer.masksToBounds = YES;
ima6.layer.cornerRadius= 25;
[celladdSubview: ima6];
UILabel* lab6 = [[UILabelalloc]initWithFrame:CGRectMake(130, 110, 60, 20)];
lab6.text=@"当前订单";
lab6.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab6];
UIImageView * ima7 = [[UIImageView alloc]initWithFrame:CGRectMake(228, 60, 50, 50)];
ima7.image = [UIImage imageNamed:@"11"];
ima7.layer.masksToBounds = YES;
ima7.layer.cornerRadius= 25;
[celladdSubview: ima7];
UILabel* lab7 = [[UILabelalloc]initWithFrame:CGRectMake(230, 110, 60, 20)];
lab7.text=@"当前订单";
lab7.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab7];
UIImageView * ima8 = [[UIImageView alloc]initWithFrame:CGRectMake(328, 60, 50, 50)];
ima8.image = [UIImage imageNamed:@"11"];
ima8.layer.masksToBounds = YES;
ima8.layer.cornerRadius= 25;
[celladdSubview: ima8];
UILabel* lab8 = [[UILabelalloc]initWithFrame:CGRectMake(330, 110, 60, 20)];
lab8.text=@"当前订单";
lab8.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab8];
}elseif(indexPath.section==2){
tbv.rowHeight= 130;
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 150, 50)];
label.text=@"我的钱包";
[celladdSubview:label];
UILabel*label2 = [[UILabelalloc]initWithFrame:CGRectMake(47, 50, 100, 50)];
label2.text=@"0元";
[celladdSubview:label2];
UILabel*label3 = [[UILabelalloc]initWithFrame:CGRectMake(20, 80, 100, 50)];
label3.text=@"可用余额";
[celladdSubview:label3];
UILabel*label4 = [[UILabelalloc]initWithFrame:CGRectMake(145, 50, 100, 50)];
label4.text=@"0";
[celladdSubview:label4];
UILabel*label5 = [[UILabelalloc]initWithFrame:CGRectMake(134, 80, 100, 50)];
label5.text=@"贝币";
[celladdSubview:label5];
UILabel*label6 = [[UILabelalloc]initWithFrame:CGRectMake(220, 50, 100, 50)];
label6.text=@"0张";
[celladdSubview:label6];
UILabel*label7 = [[UILabelalloc]initWithFrame:CGRectMake(210, 80, 100, 50)];
label7.text=@"优惠券";
[celladdSubview:label7];
UILabel*label8 = [[UILabelalloc]initWithFrame:CGRectMake(300, 50, 100, 50)];
label8.text=@"0万元";
[celladdSubview:label8];
UILabel*label9 = [[UILabelalloc]initWithFrame:CGRectMake(290, 80, 100, 50)];
label9.text=@"可借现金";
[celladdSubview:label9];
}elseif(indexPath.section==3){
tbv.rowHeight= 200;
UIImageView * ima = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, 50, 50)];
ima.image = [UIImage imageNamed:@"11"];
ima.layer.masksToBounds = YES;
ima.layer.cornerRadius= 25;
[celladdSubview: ima];
UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(24, 65, 60, 20)];
lab.text=@"当前订单";
lab.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab];
UIImageView * ima2 = [[UIImageView alloc]initWithFrame:CGRectMake(120, 10, 50, 50)];
ima2.image = [UIImage imageNamed:@"22"];
ima2.layer.masksToBounds = YES;
ima2.layer.cornerRadius= 25;
[celladdSubview: ima2];
UILabel * lab2 = [[UILabel alloc]initWithFrame:CGRectMake(124, 65, 60, 20)];
lab2.text=@"代付款";
lab2.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab2];
UIImageView * ima3 = [[UIImageView alloc]initWithFrame:CGRectMake(220, 10, 50, 50)];
ima3.image = [UIImage imageNamed:@"33"];
ima3.layer.masksToBounds = YES;
ima3.layer.cornerRadius= 25;
[celladdSubview: ima3];
UILabel * lab3 = [[UILabel alloc]initWithFrame:CGRectMake(224, 65, 60, 20)];
lab3.text=@"当前订单";
lab3.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab3];
UIImageView * ima4 = [[UIImageView alloc]initWithFrame:CGRectMake(320, 10, 50, 50)];
ima4.image = [UIImage imageNamed:@"44"];
ima4.layer.masksToBounds = YES;
ima4.layer.cornerRadius= 25;
[celladdSubview: ima4];
UILabel * lab4 = [[UILabel alloc]initWithFrame:CGRectMake(324, 65, 60, 20)];
lab4.text=@"当前订单";
lab4.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab4];
UIImageView * ima5 = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 50, 50)];
ima5.image = [UIImage imageNamed:@"11"];
ima5.layer.masksToBounds = YES;
ima5.layer.cornerRadius= 25;
[celladdSubview: ima5];
UILabel * lab5 = [[UILabel alloc]initWithFrame:CGRectMake(24, 155, 60, 20)];
lab5.text=@"当前订单";
lab5.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab5];
UIImageView * ima6 = [[UIImageView alloc]initWithFrame:CGRectMake(120, 100, 50, 50)];
ima6.image = [UIImage imageNamed:@"22"];
ima6.layer.masksToBounds = YES;
ima6.layer.cornerRadius= 25;
[celladdSubview: ima6];
UILabel* lab6 = [[UILabelalloc]initWithFrame:CGRectMake(124, 155, 60, 20)];
lab6.text=@"代付款";
lab6.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab6];
UIImageView * ima7 = [[UIImageView alloc]initWithFrame:CGRectMake(220, 100, 50, 50)];
ima7.image = [UIImage imageNamed:@"33"];
ima7.layer.masksToBounds = YES;
ima7.layer.cornerRadius= 25;
[celladdSubview: ima7];
UILabel* lab7 = [[UILabelalloc]initWithFrame:CGRectMake(224, 155, 60, 20)];
lab7.text=@"当前订单";
lab7.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab7];
UIImageView * ima8 = [[UIImageView alloc]initWithFrame:CGRectMake(320, 100, 50, 50)];
ima8.image = [UIImage imageNamed:@"44"];
ima8.layer.masksToBounds = YES;
ima8.layer.cornerRadius= 25;
[celladdSubview: ima8];
UILabel* lab8 = [[UILabelalloc]initWithFrame:CGRectMake(324, 155, 60, 20)];
lab8.text=@"当前订单";
lab8.font = [UIFont systemFontOfSize:10];
[celladdSubview:lab8];
}
returncell;
}
@end
#import "SZViewController.h"
@interface SZViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UITableView *tb;
}
@end
@implementationSZViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title=@"设置";
tb=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
tb.dataSource=self;
tb.delegate=self;
[self.view addSubview:tb];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView{
return2;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
if(section ==0) {
return9;
}
else{
return1;
}
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"2"];
if(!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"2"];
}
if(indexPath.section==0) {
tb.rowHeight=40;
NSArray*arr;
arr=[NSArray arrayWithObjects:@"个人资料",@"账户与安全",@"我的地址",@"意见反馈",@"账号与s设备安全",@"证件信息",@"推送通知",@"清除缓存",@"关于贝店", nil];
cell.textLabel.text=arr[indexPath.row];
}
else{
UILabel *lb =[[UILabel alloc]initWithFrame:CGRectMake((self.view.frame.size.width-80)/2, 0,80,40)];
lb.text=@"退出登录";
lb.textColor=[UIColor redColor];
[celladdSubview:lb];
}
returncell;
}
@end
网友评论