【练习LV2】home ==> four

来源:互联网 发布:网络道德存在的问题 编辑:程序博客网 时间:2024/06/07 08:41

//  FourViewController.h


#import <UIKit/UIKit.h>

#import "SZViewController.h"   //设置

#import "ZHYAQViewController.h"//账户与安全

#import "YEViewController.h"   //银行卡

#import "YHKViewController.h"  //余额

#import "YEBViewController.h"  //余额宝

#import "ZCBViewController.h"  //招财宝

#import "YLBViewController.h"  //娱乐宝

#import "ZMXYFViewController.h"//芝麻信用分

#import "WDBZViewController.h" //我的保障

#import "AXJZViewController.h" //爱心捐赠


@interface FourViewController :UIViewController<UIGestureRecognizerDelegate,UITableViewDataSource,UITableViewDelegate>


//tableview声明几个数组,因为打算分三个区

@property(nonatomic,retain)NSArray*text_Array1;

@property(nonatomic,retain)NSArray*text_Array2;

@property(nonatomic,retain)NSArray*text_Array3;


@property(nonatomic,retain)NSArray*picture_Array1;

@property(nonatomic,retain)NSArray*picture_Array2;

@property(nonatomic,retain)NSArray*picture_Array3;


@end




//  FourViewController.m


#import "FourViewController.h"


@interface FourViewController ()

{

//导航栏

   UIView*nav_View;

   UIButton*navright_Button;

   UIButton*navleft_Button;

   UILabel*title_Label;

    

//资料栏

   UIView*zl_view1;

   UIView*ye_view2;

   UIView*yhk_view3;

}

@end


@implementation FourViewController


@synthesize text_Array1;

@synthesize text_Array2;

@synthesize text_Array3;

@synthesize picture_Array1;

@synthesize picture_Array2;

@synthesize picture_Array3;


/////////////////////       隐藏系统的navigationbartabbar,显示自定义的tabbar      //////////////////////////////////////

-(void)viewWillAppear:(BOOL)animated

{

    self.navigationController.navigationBarHidden =YES;

    self.tabBarController.tabBar.hidden =YES;

    [[NSNotificationCenterdefaultCenter] postNotificationName:@"bringCustomTabBarToFront"object:nil];

}

- (void)viewDidLoad{

    [superviewDidLoad];

    

//////////////////////////      导航栏的自定义     /////////////////////////////////

    nav_View=[[UIViewalloc]initWithFrame:CGRectMake(0,20, self.view.bounds.size.width,44)];

    nav_View.backgroundColor=[UIColorblackColor];

    [self.viewaddSubview:nav_View];

    

/////////////////////       标题      //////////////////////////////////////

    title_Label=[[UILabelalloc]initWithFrame:CGRectMake(100,27, 120, 30)];

    title_Label.text=@"财富";

    title_Label.textAlignment=NSTextAlignmentCenter;

    title_Label.textColor=[UIColorwhiteColor];

    title_Label.font=[UIFontsystemFontOfSize:20];

    [self.viewaddSubview:title_Label];

    

/////////////////////       右边      //////////////////////////////////////

    navright_Button=[[UIButtonalloc]initWithFrame:CGRectMake(self.view.bounds.size.width-65,27, 50, 30)];

    [navright_ButtonsetTitle:@"设置"forState:UIControlStateNormal];

    navright_Button.titleLabel.textAlignment=NSTextAlignmentRight;

    navright_Button.titleLabel.font=[UIFontsystemFontOfSize:16];

    [navright_ButtonaddTarget:selfaction:@selector(navright)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:navright_Button];

    

////////////////////////    资料栏{本地数据,还未学习联网数据}      / //////////////////

//创建A视图,个人资料

    zl_view1=[[UIViewalloc]initWithFrame:CGRectMake(0,nav_View.bounds.size.height+20,self.view.bounds.size.width,70)];

    zl_view1.backgroundColor=[UIColoryellowColor];

    

//A视图上加载图片

   UIImageView*zl_imageView1=[[UIImageViewalloc]initWithFrame:CGRectMake(10,10,50, 50)];

    [zl_imageView1setImage:[UIImageimageNamed:@"1"]];

    [zl_view1addSubview:zl_imageView1];

    

//A视图上加载文字1

   UILabel*zl_Label1=[[UILabelalloc]initWithFrame:CGRectMake(70,20, 80, 20)];

    zl_Label1.text=@"王二狗";

    zl_Label1.font=[UIFontsystemFontOfSize:16];

    [zl_view1addSubview:zl_Label1];

    

//A视图上加载文字2

   UILabel*zl_Label2=[[UILabelalloc]initWithFrame:CGRectMake(70,40, 80, 20)];

    zl_Label2.font=[UIFontsystemFontOfSize:14];

    zl_Label2.text=@"187XXXXXXXXX";

    [zl_view1addSubview:zl_Label2];

    

//原视图上加载A视图

    [self.viewaddSubview:zl_view1];


//创建A视图点击事件,声明方法-(void)toGeRen.h文件注意代理@interface FourViewController : UIViewController<UIGestureRecognizerDelegate>

    zl_view1.userInteractionEnabled=YES;

    UITapGestureRecognizer*geren_Tap=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(toGeRen:)];

    [zl_view1addGestureRecognizer:geren_Tap];

    

////////////////////////////////    余额(方法同上)    /////////////////////////////////////

    

    ye_view2=[[UIViewalloc]initWithFrame:CGRectMake(0,zl_view1.bounds.size.height+nav_View.bounds.size.height+20,self.view.bounds.size.width/2,30)];      //y的值还有待研究

    ye_view2.backgroundColor=[UIColorredColor];

    

   UILabel*ye_Label1=[[UILabelalloc]initWithFrame:CGRectMake(10,10, self.view.bounds.size.width/4-10,10)];

    ye_Label1.text=@"余额";

    ye_Label1.font=[UIFontsystemFontOfSize:13];

    [ye_view2addSubview:ye_Label1];

    

    UILabel*ye_Labe2=[[UILabelalloc]initWithFrame:CGRectMake(self.view.bounds.size.width/4,10, self.view.bounds.size.width/4-10,10)];

    ye_Labe2.text=@"2222.22";

    ye_Labe2.font=[UIFontsystemFontOfSize:13];

    [ye_view2addSubview:ye_Labe2];

    ye_Labe2.textAlignment=NSTextAlignmentRight;

    

    [self.viewaddSubview:ye_view2];

     

    ye_view2.userInteractionEnabled=YES;

    UITapGestureRecognizer*ye_Tap=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(toYE:)];

    [ye_view2addGestureRecognizer:ye_Tap];

    

////////////////////////////////    银行卡(方法同上)   /////////////////////////////////////

    

    yhk_view3=[[UIViewalloc]initWithFrame:CGRectMake(self.view.bounds.size.width/2,zl_view1.bounds.size.height+nav_View.bounds.size.height+20,self.view.bounds.size.width/2,30)];      //y的值还有待研究

    yhk_view3.backgroundColor=[UIColorgreenColor];

    

   UILabel*yhk_Label1=[[UILabelalloc]initWithFrame:CGRectMake(10,10, self.view.bounds.size.width/4-10,10)];

    yhk_Label1.text=@"银行卡";

    yhk_Label1.font=[UIFontsystemFontOfSize:13];

    [yhk_view3addSubview:yhk_Label1];

    

    UILabel*yhk_Label2=[[UILabelalloc]initWithFrame:CGRectMake(self.view.bounds.size.width/4,10, self.view.bounds.size.width/4-10,10)];

    yhk_Label2.text=@"4";

    yhk_Label2.font=[UIFontsystemFontOfSize:13];

    yhk_Label2.textAlignment=NSTextAlignmentRight;

    [yhk_view3addSubview:yhk_Label2];

    

    [self.viewaddSubview:yhk_view3];

    

    

    yhk_view3.userInteractionEnabled=YES;

    UITapGestureRecognizer*yhk_Tap=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(toYHK:)];

    [yhk_view3addGestureRecognizer:yhk_Tap];

    

 

////////////////////////////////    表格栏tabbarview   /////////////////////////////////////

    

   NSArray*tArray1=[[NSArrayalloc]initWithObjects:@"余额宝",@"找财报",@"娱乐宝",nil];

   text_Array1=tArray1;

    

   NSArray*tArray2=[[NSArrayalloc]initWithObjects:@"芝麻信用分",@"我的保障",nil];

   text_Array2=tArray2;

    

   NSArray*tArray3=[[NSArrayalloc]initWithObjects:@"爱心捐赠",nil];

   text_Array3=tArray3;

    

    NSArray*pArray1=[[NSArrayalloc]initWithObjects:[UIImageimageNamed:@"1"], [UIImageimageNamed:@"2"],[UIImageimageNamed:@"3"],nil];

    picture_Array1=pArray1;

    

    NSArray*pArray2=[[NSArrayalloc]initWithObjects:[UIImageimageNamed:@"4"],[UIImageimageNamed:@"5"],nil];

    picture_Array2=pArray2;

    

    NSArray*pArray3=[[NSArrayalloc]initWithObjects:[UIImageimageNamed:@"6"],nil];

    picture_Array3=pArray3;

    

    UITableView*cf_tableview=[[UITableViewalloc]initWithFrame:CGRectMake(0,zl_view1.bounds.size.height+nav_View.bounds.size.height+20+yhk_view3.bounds.size.height,self.view.bounds.size.width,500) style:UITableViewStyleGrouped];

    cf_tableview.delegate=self;

    cf_tableview.dataSource=self;

    

    [cf_tableviewsetScrollEnabled:NO];    //不能滚动

    

    [self.viewaddSubview:cf_tableview];

    


 

}

//多少组

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

   return 3;

}


//每组多少个


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

   if (section==0) {

       return 3;

    }elseif (section==1){

       return 2;

    }else

       return 1;

}


//创建cell,加载内容

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


{

   static NSString*CellIdentifier=@"Cell";

   UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

   if (cell==nil) {

        cell=[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier];

    }

    

   if (indexPath.section==0) {

        cell.textLabel.text=[text_Array1objectAtIndex:[indexPath row]];

        cell.imageView.image=[picture_Array1objectAtIndex:[indexPath row]];

        

    }elseif (indexPath.section==1){

        cell.textLabel.text=[text_Array2objectAtIndex:[indexPath row]];

        cell.imageView.image=[picture_Array2objectAtIndex:[indexPath row]];

        

    }else{

        cell.textLabel.text=[text_Array3objectAtIndex:[indexPath row]];

        cell.imageView.image=[picture_Array3objectAtIndex:[indexPath row]];

    }

    

   return cell;

}


//导航栏右键,设置

-(void)navright

{

    SZViewController*sz_view=[[SZViewControlleralloc]init];

    self.hidesBottomBarWhenPushed=YES;

    sz_view.hidesBottomBarWhenPushed =YES;

    [self.tabBarController.tabBarsetHidden:YES];

    [self.navigationControllerpushViewController:sz_view animated:YES]; 

}


//点击个人资料  与隐藏tabbar 有关(点击手势)

-(void)toGeRen:(UITapGestureRecognizer*)gesture

{

    ZHYAQViewController*zhyaq_View=[[ZHYAQViewControlleralloc]init];

    zhyaq_View.hidesBottomBarWhenPushed =YES;

    [self.tabBarController.tabBarsetHidden:YES];

    [self.navigationControllerpushViewController:zhyaq_View animated:YES]; 

}


//点击余额

-(void)toYE:(UITapGestureRecognizer*)gesture

{

    YEViewController*ye_View=[[YEViewControlleralloc]init];

    ye_View.hidesBottomBarWhenPushed =YES;

    [self.tabBarController.tabBarsetHidden:YES];

    [self.navigationControllerpushViewController:ye_View animated:YES];

    

}


//点击银行卡

-(void)toYHK:(UITapGestureRecognizer*)gesture

{

    YHKViewController*yhk_View=[[YHKViewControlleralloc]init];

    yhk_View.hidesBottomBarWhenPushed =YES;

    [self.tabBarController.tabBarsetHidden:YES];

    [self.navigationControllerpushViewController:yhk_View animated:YES];

    

}


////////////////////////////分区的间距,头,尾////////////////////////

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

   return 15;

}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

{

   return 1;

}



//////////////////////////////////////     cell 点击  //////////////////////////////////////

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

   if (indexPath.section==0) {

       if (indexPath.row==0) {

            YEBViewController*yebView=[[YEBViewControlleralloc]init  ];

            yebView.hidesBottomBarWhenPushed =YES;

            [self.tabBarController.tabBarsetHidden:YES];

            [self.navigationControllerpushViewController:yebView animated:YES];

        }elseif (indexPath.row==1){

            ZCBViewController*zcbView=[[ZCBViewControlleralloc]init];

            zcbView.hidesBottomBarWhenPushed =YES;

            [self.tabBarController.tabBarsetHidden:YES];

            [self.navigationControllerpushViewController:zcbView animated:YES];

        }else{

            YLBViewController*ylbView=[[YLBViewControlleralloc]init];

            ylbView.hidesBottomBarWhenPushed =YES;

            [self.tabBarController.tabBarsetHidden:YES];

            [self.navigationControllerpushViewController:ylbView animated:YES];

        }

    }elseif (indexPath.section==1){

       if (indexPath.row==0) {

            ZMXYFViewController*zmxyfView=[[ZMXYFViewControlleralloc]init];

            zmxyfView.hidesBottomBarWhenPushed =YES;

            [self.tabBarController.tabBarsetHidden:YES];

            [self.navigationControllerpushViewController:zmxyfView animated:YES];

        }else{

            WDBZViewController*wdbzView=[[WDBZViewControlleralloc]init];

            wdbzView.hidesBottomBarWhenPushed =YES;

            [self.tabBarController.tabBarsetHidden:YES];

            [self.navigationControllerpushViewController:wdbzView animated:YES];

        }

    }else{

            AXJZViewController*axjzView=[[AXJZViewControlleralloc]init];

        axjzView.hidesBottomBarWhenPushed =YES;

        [self.tabBarController.tabBarsetHidden:YES];

            [self.navigationControllerpushViewController:axjzView animated:YES];

    }

}



- (void)didReceiveMemoryWarning

{

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


/*

#pragma mark - Navigation


// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/




@end




0 0
原创粉丝点击