| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // TongyongDetailViewController.m
- // jitao
- //
- // Created by 罗云飞 on 2018/8/19.
- // Copyright © 2018年 罗云飞. All rights reserved.
- //
- #import "TongyongDetailViewController.h"
- @interface TongyongDetailViewController ()<UIWebViewDelegate>{
- 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:@"<h4 style='text-align:center;font-size:20px'>标题</h4><p style='text-align:right'>2018-10-12</p >" atIndex:0];
- NSString *strUrl = [string stringByReplacingOccurrencesOfString:@"//statics" withString:@"http://statics"];//替换字符
- // NSString *fffff = [strUrl stringByReplacingOccurrencesOfString:@"<img" withString:@"< img style=\"width:100%\" "];//替换字符
- NSString *htmlString = [NSString stringWithFormat:@"<html> \n"
- "<head> \n"
- "<style type=\"text/css\"> \n"
- "body {font-size:15px;}\n"
- "</style> \n"
- "</head> \n"
- "<body>"
- "<script type='text/javascript'>"
- "window.onload = function(){\n"
- "var $img = document.getElementsByTagName('img');\n"
- "for(var p in $img){\n"
- " $img[p].style.width = '100%%';\n"
- "$img[p].style.height ='auto'\n"
- "}\n"
- "}"
- "</script>%@"
- "</body>"
- "</html>", 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
|