// // ReleaseresultsViewController.m // jitao // // Created by 罗云飞 on 2018/1/16. // Copyright © 2018年 罗云飞. All rights reserved. // #import "ReleaseresultsViewController.h" #import "ReleaseresultsCell.h" #import "ResultsdescriptionCell.h"// #import "ResultsTitleCell.h" #define Start_X 15 // 第一个按钮的X坐标 #define Start_Y 10.0f // 第一个按钮的Y坐标 #define Width_Space 10.0f // 2个按钮之间的横间距 #define Height_Space 10.0f // 竖间距 #define Button_Height 30.0f // 高 //#define Button_Width (SCREEN_WIDTH-60)/4 // 宽 #define Button_Width 60 // 宽 @interface ReleaseresultsViewController (){ UITableView *newtableView; NSMutableArray *dataArray; NSMutableArray *titledataArray;//标题数组 NSMutableArray *updateArr; NSString *descriptionStr;//成果描述 接收字符串 NSString *resultsTitleStr;//成果标题 接收字符 UIButton *updatefrequencybtn;//更新频率 BOOL isseemore;//查看更多 NSString *technicaltypeStr; NSString *technicaltypeTag; } @end @implementation ReleaseresultsViewController - (void)viewDidLoad { [super viewDidLoad]; [self setNavTitle:@"发布成果"]; [self dataInitialization]; [self Networkrequest]; [self loadsView]; // Do any additional setup after loading the view. } - (void)dataInitialization { isseemore = YES; dataArray = NewMutableArrayInit; titledataArray = [NSMutableArray arrayWithObjects:@"成果描述",@"成果标题",@"技术类型",@"其他",@"成果配图", nil]; NSArray *arr = @[@"专利专利",@"专利专利",@"专利专利",@"专利专利"]; updateArr = [NSMutableArray arrayWithArray:arr]; } - (void)Networkrequest { } #pragma mark ----加载界面 - (void)loadsView{ [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeader) backgroundColor:NewLineGrayColor style:UITableViewStyleGrouped delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]]; newtableView.separatorStyle = NO; } #pragma mark-------------------------UITableView------------------------------------ -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 5; } //返回每段行数 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0||section == 1||section == 2) { return 1; }else if (section == 3){ return 4; } return 3; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *Cell = @"Cell"; static NSString *Cell1 = @"Cell1"; static NSString *Cell2 = @"Cell2"; if (indexPath.section == 0) { ResultsdescriptionCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell]; if (cell == nil) { cell = [[ResultsdescriptionCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果) cell.accessoryType = UITableViewCellAccessoryNone; // [cell assignment:dataArray[indexPath.row]]; cell.backgroundColor = NewLineGrayColor; cell.textview.delegate = self; return cell; }else if (indexPath.section == 1){ ResultsTitleCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1]; if (cell == nil) { cell = [[ResultsTitleCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果) cell.accessoryType = UITableViewCellAccessoryNone; cell.backgroundColor = NewLineGrayColor; [cell.textfield addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged]; return cell; }else if (indexPath.section == 2){ UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果) cell.accessoryType = UITableViewCellAccessoryNone; cell.backgroundColor = NewLineGrayColor; if (isseemore) { NSLog(@"更多1"); NSArray *arr = @[@"专利专利",@"专利专利",@"专利专利",@"专利专利"]; [updateArr removeAllObjects]; updateArr = [NSMutableArray arrayWithArray:arr]; }else{ NSLog(@"更多2"); NSArray *arr = @[@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利",@"专利专利"]; [updateArr removeAllObjects]; updateArr = [NSMutableArray arrayWithArray:arr]; } UIView *view = [[UIView alloc] init]; CGFloat page = updateArr.count/4; view.frame = CGRectMake(0, 0, SCREEN_WIDTH, page * (Button_Height + Height_Space)+10); view.backgroundColor = NewLineGrayColor; [cell.contentView addSubview:view]; for (int i = 0; i 500){ textView.text = [textView.text substringWithRange:NSMakeRange(0,500)]; } if (textView.text.length > 0) { NSLog(@"textView.text:%@",textView.text); if ([textView.text isEqualToString:@"请描述您的技术成果~"]) { descriptionStr = @""; }else{ descriptionStr = nil; descriptionStr = textView.text; } } } #pragma mark - TextField作字符输入限制 - (void)textFieldEditingChanged:(UITextField *)textField { if ([textField.text length]>50) { UITextRange *markedRange = [textField markedTextRange]; if (markedRange) { return; } NSRange range = [textField.text rangeOfComposedCharacterSequenceAtIndex:50]; textField.text = [textField.text substringToIndex:range.location]; [self.view makeToast:@"标题最多输入50个字哦~" duration:1.5 position:CSToastPositionCenter]; } resultsTitleStr = textField.text; NSLog(@"%@",resultsTitleStr); } - (void)seemoreclick:(UIButton *)sender { NSLog(@"点击查看更多"); sender.selected = !sender.selected; if (!sender.selected) { isseemore = YES; }else{ isseemore = NO; } NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:2]; [newtableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone]; // updatefrequencybtn = nil; } - (void)updatefrequencybtnclick:(UIButton *)sender { if(updatefrequencybtn == sender) { //针对最后一个按钮创建 NSLog(@"1111"); } else{ //本次点击的按钮设为白色 [sender setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [sender setBackgroundColor:NewButtonColor]; ViewBorderRadius(sender, 10, 0.6, NewButtonColor); //将上次点击过的按钮设为蓝色 [updatefrequencybtn setTitleColor:NewButtonColor forState:UIControlStateNormal]; [updatefrequencybtn setBackgroundColor:NewWhiteColor]; ViewBorderRadius(updatefrequencybtn, 10, 0.6, NewButtonColor); } updatefrequencybtn = sender; technicaltypeTag = [NSString stringWithFormat:@"%ld",sender.tag]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:2]; [newtableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone]; NSLog(@"%@",technicaltypeStr); } - (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