You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.9 KiB
104 lines
3.9 KiB
![]()
2 years ago
|
//
|
||
|
// SelectViewController.m
|
||
|
// myWear
|
||
|
//
|
||
|
// Created by xTT on 2017/2/22.
|
||
|
// Copyright © 2017年 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "SelectWeekViewController.h"
|
||
|
|
||
|
#import "VoiceAlarm.h"
|
||
|
#import "DisturbBan.h"
|
||
|
|
||
|
@interface SelectWeekViewController ()
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation SelectWeekViewController
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
[self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(self.view);
|
||
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight);
|
||
|
make.bottom.equalTo(self.view.mas_bottom);
|
||
|
}];
|
||
|
self.navigationItem.title = @"重复";
|
||
|
self.myDataSource = [NSMutableArray arrayWithArray:@[@[@"周一",@"周二",@"周三",@"周四",@"周五",@"周六",@"周日"]]];
|
||
|
self.weekDayArr = [myHelper getWeekStr:[self.model valueForKey:@"week"] removedNil:NO];
|
||
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存"
|
||
|
style:UIBarButtonItemStylePlain
|
||
|
target:self
|
||
|
action:@selector(rightBarItemClick:)];
|
||
|
[self.view addSubview:self.myTableView];
|
||
|
}
|
||
|
|
||
|
#pragma mark 保存选择的周几
|
||
|
- (IBAction)rightBarItemClick:(UIBarButtonItem *)sender{
|
||
|
NSMutableArray *arr = [myHelper getWeekDayDataArr:_weekDayArr];
|
||
|
if ([self.model isKindOfClass:[DisturbBan class]] && ![arr containsObject:@"1"]) {
|
||
|
[SVProgressHUD showErrorWithStatus:@"至少需选择一天"];
|
||
|
}else{
|
||
|
[self.model setValue:[arr componentsJoinedByString:@""] forKey:@"week"];
|
||
|
[self goBack:sender];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
#pragma tableView
|
||
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
|
return 0.015;
|
||
|
}
|
||
|
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||
|
return [UIView new];
|
||
|
}
|
||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
|
||
|
if (!cell) {
|
||
|
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
|
||
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
|
[cell setBackgroundColor:cellBG];
|
||
|
cell.textLabel.text = [NSString stringWithFormat:@"每%@",self.myDataSource[indexPath.section][indexPath.row]];
|
||
|
}
|
||
|
if ([_weekDayArr containsObject:self.myDataSource[indexPath.section][indexPath.row]]) {
|
||
|
cell.accessoryView = [[UIImageView alloc] initWithImage:[myHelper getImageWithName:@"选中"]];
|
||
|
}else{
|
||
|
cell.accessoryView = [[UIImageView alloc] initWithImage:[myHelper getImageWithName:@"未选中"]];
|
||
|
}
|
||
|
|
||
|
return cell;
|
||
|
}
|
||
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
xLog(@"点击");
|
||
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||
|
if ([_weekDayArr containsObject:self.myDataSource[indexPath.section][indexPath.row]]) {
|
||
|
[_weekDayArr replaceObjectAtIndex:indexPath.row withObject:@""];
|
||
|
}else{
|
||
|
[_weekDayArr replaceObjectAtIndex:indexPath.row withObject:self.myDataSource[indexPath.section][indexPath.row]];
|
||
|
}
|
||
|
[tableView reloadData];
|
||
|
|
||
|
}
|
||
|
- (void)didReceiveMemoryWarning {
|
||
|
[super didReceiveMemoryWarning];
|
||
|
// Dispose of any resources that can be recreated.
|
||
|
}
|
||
|
|
||
|
|
||
|
- (void)dealloc{
|
||
|
|
||
|
}
|
||
|
/*
|
||
|
#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
|