|
//
// TPReadKindVC.m
// ThePaperBase
//
// Created by zhousan on 15/8/17.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "TPReadKindVC.h"
#import "ReadDefaultCell.h"
@interface TPReadKindVC () <UITableViewDataSource,UITableViewDelegate> {
UIButton *btn1;
UIButton *btn2;
UIButton *btn3;
}
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, assign) NSInteger index;
@end
@implementation TPReadKindVC
@synthesize index = _index;
- (void)viewDidLoad {
[super viewDidLoad];
self.titleStr = @"阅读模式";
[self.view addSubview:self.tableView];
[self.tableView reloadData];
self.index = [[TPUserDefault instance].readModeStr intValue];
}
- (void)setIndex:(NSInteger)idx {
_index = idx;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[TPUserDefault instance].readModeStr = [NSString stringWithFormat:@"%ld", (long)self.index];
}
#pragma mark - tableView Getting
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.barHeight, rect_screen.size.width, rect_screen.size.height-self.barHeight) style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.clipsToBounds = YES;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_tableView.scrollEnabled = NO;
}
return _tableView;
}
#pragma mark - tableView DataSouse
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellId = @"CellId";
ReadDefaultCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[ReadDefaultCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
cell.rightBtn.tag = indexPath.row + 1000;
if (indexPath.row == 0) {
btn1 = cell.rightBtn;
}else if (indexPath.row == 1) {
btn2 = cell.rightBtn;
}else if (indexPath.row == 2) {
btn3 = cell.rightBtn;
}
if (self.index == 0) {
[btn1 setSelected:YES];
[btn2 setSelected:NO];
[btn3 setSelected:NO];
}else if (self.index == 1) {
[btn1 setSelected:NO];
[btn2 setSelected:YES];
[btn3 setSelected:NO];
}else {
[btn1 setSelected:NO];
[btn2 setSelected:NO];
[btn3 setSelected:YES];
}
// [cell.rightBtn addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
switch (indexPath.row) {
case 0:
cell.firstString = @"图文模式";
cell.secondString = @"总是加载图片";
break;
case 1:
cell.firstString = @"文本模式";
cell.secondString = @"不加载图片";
break;
case 2:
cell.firstString = @"智能模式";
cell.secondString = @"仅WiFi环境下加载图片";
break;
default:
break;
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
self.index = indexPath.row;
switch (indexPath.row) {
case 0:
[btn1 setSelected:YES];
[btn2 setSelected:NO];
[btn3 setSelected:NO];
break;
case 1:
[btn1 setSelected:NO];
[btn2 setSelected:YES];
[btn3 setSelected:NO];
[MobClick event:@"28"];
break;
case 2:
[btn1 setSelected:NO];
[btn2 setSelected:NO];
[btn3 setSelected:YES];
[MobClick event:@"27"];
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// 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
|