BFSettingVController

//
//  QiuySetViewController.h
//  QiuySetVController
//
//  Created by laizhenjie on 14-3-20.
//  Copyright (c) 2014年 Laizhenjie. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface QiuySetViewController : UIViewController

@property(nonatomic, retain) UIView *backgroundView;
@property(nonatomic, strong) UITableView *setTabView;
@property(nonatomic, strong) NSMutableArray *setArray;
@property(nonatomic, strong) NSMutableArray *setArrayUlogin;
@property(nonatomic, strong) NSMutableArray *setArrayLogin;

@property(nonatomic, assign) BOOL isLogin;

@end



//
//  QiuySetViewController.m
//  QiuySetVController
//
//  Created by laizhenjie on 14-3-20.
//  Copyright (c) 2014年 Laizhenjie. All rights reserved.
//

#import "QiuySetViewController.h"
#define KLOING_YES 0


typedef enum{
   
    UCLoginCellTypeLogin = 0,
    UCLoginCellTypeSina ,
    UCLoginCellTypeTencent,

    UCLoginCellTypeMessageSet = 10,
    UCLoginCellTypeMessageRemainVoice,
    UCLoginCellTypeMessageThrill,
    
    UCLoginCellTypeClearList = 20,
    UCLoginCellTypeClearChartRecord,

    UCLoginCellTypeFeedback = 30,
    UCLoginCellTypeDeclare,
    UCLoginCellTypeOther,
    UCLoginCellTypeAbout,
    
} UCLoginCellType;


typedef enum{
    
    UCUnLoginCellTypeLogin = 0,
    UCUnLoginCellTypeSina,
    UCUnLoginCellTypeTencent,
    
    UCUnLoginCellTypeMessageSet = 10,
    UCUnLoginCellTypeMessageRemainVoice,
    UCUnLoginCellTypeMessageThrill,
    
    UCUnLoginCellTypeFeedback = 20,
    UCUnLoginCellTypeDeclare ,
    UCUnLoginCellTypeOther,
    UCUnLoginCellTypeAbout,
    
} UCUnLoginCellType;



@interface QiuySetViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation QiuySetViewController

@synthesize backgroundView;
@synthesize setArray;
@synthesize setTabView;

@synthesize setArrayUlogin;
@synthesize setArrayLogin;
@synthesize isLogin;




- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor brownColor]];
    
    [self initBackgroundView:self.view.frame];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}


#pragma mark 設置第二父背景
- (void)initBackgroundView:(CGRect)frame{
    
    UIButton *refreshButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    refreshButton.frame = CGRectMake(282, 22.f, 44, 28);
    refreshButton.backgroundColor = [UIColor blueColor];
    [refreshButton addTarget:self action:@selector(loginYN:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:refreshButton];
    isLogin = NO;

    backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0.f, 66.f, frame.size.width, frame.size.height-66.f)];
    [backgroundView setBackgroundColor:[UIColor whiteColor]];
    [self.view addSubview:backgroundView];
    [self initTabView];
    
}


#pragma mark -列表生成
- (void)initTabView{
    
//    未登陸
//    1、賬號綁定:
//    登錄  文字    >    -->登錄頁面
//    新浪微博  綁定 >
//    QQ賬號   綁定 >
//    2、提醒設置
//    消息提醒設置
//    消息提醒音  Btn
//    消息提醒震動 Btn
//
//    3、 消息設置
//    清空消息列表  >
//    清空聊天記錄  >
    
//    4、其它
//    意見反饋 >
//    免責聲明 >
//    其它功能 >
//    關於 >

    
    NSArray *accountBindArr = [[NSArray alloc]initWithObjects:@"登錄",@"新浪微博",@"QQ帳號", nil];
    NSArray *remainSetArr = [[NSArray alloc]initWithObjects:@"消息提醒設置",@"消息提醒音  Btn",@"消息提醒震動 Btn", nil];
    NSArray *messageSetArr = [[NSArray alloc]initWithObjects:@"清空消息列表",@"清空聊天記錄", nil];
    NSArray *otherArr = [[NSArray alloc]initWithObjects:@"意見反饋",@"免責聲明",@"其它功能", @"關於", nil];
    setArrayLogin = [[NSMutableArray alloc]initWithObjects:accountBindArr, remainSetArr, messageSetArr, otherArr, nil];
    setArrayUlogin = [[NSMutableArray alloc]initWithObjects:accountBindArr, remainSetArr, otherArr, nil];
    
    if (isLogin) {
        setArray = [NSMutableArray arrayWithArray:setArrayLogin];
    }else{
    
        setArray = [NSMutableArray arrayWithArray:setArrayUlogin];

    }
    
    setTabView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, backgroundView.frame.size.width, backgroundView.frame.size.height) style:UITableViewStyleGrouped];
    [setTabView setDataSource:self];
    [setTabView setDelegate:self];
    [backgroundView addSubview:setTabView];
    
}


#pragma mark -Tableview delegate method;

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return [setArray count];
   
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
 
    return [[setArray objectAtIndex:section] count];
}


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


    return 5.f;
    
}

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

    return 10.f;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    NSLog(@"section:%i, row:%i",indexPath.section, indexPath.row);
    if ((indexPath.section == 0) && (indexPath.row == 0)) {
        return 66.f;
    }
    return 45.f;
}


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

    static NSString *setCellIdentifier = @"setCellIdentifier";
    UITableViewCell *setCell = [tableView  dequeueReusableCellWithIdentifier:setCellIdentifier];
    
    if (setCell == nil){
        setCell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:setCellIdentifier];
    }
    
    setCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    [setCell.textLabel setText:[[setArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]];
    
    // 不同風格的Cell(有按鈕的cell)
    if ((indexPath.section == 1)&&(indexPath.row >0)) {
        
        setCell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return setCell;
}


- (NSIndexPath*)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{


    if ((indexPath.section == 1)&&(indexPath.row > 0)) {
        return nil;
    }
    return indexPath;
}

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

    NSLog(@"---------indexPath:section %i,row %i",indexPath.section, indexPath.row);
    NSInteger cellType = 10;
    cellType = cellType * indexPath.section + indexPath.row;
    
    if (!isLogin) {
        
    
    switch (cellType) {
        case UCUnLoginCellTypeLogin:
            NSLog(@"UCUnLoginCellTypeLogin..");
            break;
        case UCUnLoginCellTypeSina:
            NSLog(@"UCUnLoginCellTypeSina..");
            break;
        case UCUnLoginCellTypeFeedback:
            NSLog(@"UCUnLoginCellTypeFeedback..");
            break;
        case UCUnLoginCellTypeAbout:
            NSLog(@"UCUnLoginCellTypeAbout..");
            break;
            
        default:
            break;
    }
  }else
  {
  
      switch (cellType) {
          case UCLoginCellTypeLogin:
              NSLog(@"UCLoginCellTypeLogin..");
              break;
          case UCLoginCellTypeSina:
              NSLog(@"UCLoginCellTypeSina..");
              break;
          case UCLoginCellTypeFeedback:
              NSLog(@"UCLoginCellTypeFeedback..");
              break;
          case UCLoginCellTypeAbout:
              NSLog(@"UCLoginCellTypeAbout..");
              break;
              
          default:
              break;
      }

  }
}

//======================================================================

- (void)loginYN:(UIButton*)sender{

    NSLog(@"loginYN:");
    isLogin = !isLogin;
    NSLog(@"Is login:%i", isLogin);
    if (isLogin) {
        setArray = setArrayLogin;
    }else{
    
        setArray = setArrayUlogin;
    }
    
    [setTabView reloadData];
    
}

@end

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章