// // TongyongDetailViewController.m // jitao // // Created by 罗云飞 on 2018/8/19. // Copyright © 2018年 罗云飞. All rights reserved. // #import "TongyongDetailViewController.h" @interface TongyongDetailViewController (){ UITableView *newtableView; UIWebView *_myWebView; } @end @implementation TongyongDetailViewController - (void)viewDidLoad { [super viewDidLoad]; [self setNavTitle:[NSString stringWithFormat:@"%@详情",self.type]]; [self loadUI]; // Do any additional setup after loading the view. } - (void)loadUI{ [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT) backgroundColor:NewWhiteColor style:1 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 1; } //返回每段行数 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *Cell = @"Cell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果) cell.accessoryType = UITableViewCellAccessoryNone; // UILabel *title = [UILabel new]; // title.text = self.title; // title.font = NewFont(17); // title.textAlignment = NSTextAlignmentCenter; // [cell.contentView addSubview:title]; // // title.sd_layout // .leftSpaceToView(cell.contentView, 15) // .topSpaceToView(cell.contentView, 30) // .rightSpaceToView(cell.contentView, 15) // .autoHeightRatio(0); // // UILabel *time = [UILabel new]; // time.text = self.time; // time.font = NewFont(15); // [time setSingleLineAutoResizeWithMaxWidth:0]; // time.textColor = [UIColor colorWithString:@"#6C6C6C"]; // [cell.contentView addSubview:time]; // // time.sd_layout // .rightSpaceToView(cell.contentView, 15) // .heightIs(15) // .topSpaceToView(title, 20); _myWebView = [[UIWebView alloc] init]; // [_myWebView.scrollView setDelegate:self]; [_myWebView setDelegate:self]; _myWebView.scrollView.tag = 112; _myWebView.backgroundColor = [UIColor clearColor]; //自动对页面进行缩放以适应屏幕 // [_myWebView setScalesPageToFit:YES]; [cell.contentView addSubview:_myWebView]; _myWebView.sd_layout .leftSpaceToView(cell.contentView, 0) .rightSpaceToView(cell.contentView, 0) .bottomSpaceToView(cell.contentView, 0) .topSpaceToView(cell.contentView, 0); if (self.neirong.length>0) { NSMutableString *string = [NSMutableString stringWithString:self.neirong]; [string insertString:@"

标题

2018-10-12

" atIndex:0]; NSString *strUrl = [string stringByReplacingOccurrencesOfString:@"//statics" withString:@"http://statics"];//替换字符 // NSString *fffff = [strUrl stringByReplacingOccurrencesOfString:@" \n" " \n" " \n" " \n" "" "%@" "" "", strUrl]; NSLog(@"===== %@",htmlString); [_myWebView loadHTMLString:htmlString baseURL:nil]; } return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGFloat width = [NewUtils heightforString:self.neirong andWidth:SCREEN_WIDTH-30 fontSize:16]; return SCREEN_HEIGHT+width; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return CGFLOAT_MIN; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return CGFLOAT_MIN; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [[UIView alloc] init]; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { return [[UIView alloc] init]; } - (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