zoukankan      html  css  js  c++  java
  • UIWebView 里设置Text的自定义高度

    /*NSString *text = [NSString stringWithFormat:@"<html> \n"
    "<head> \n"
    "<style type=\"text/css\"> \n"
    "body{font-family:\"%@\";font-size:%f;} \n"
    "</style> \n"
    "</head> \n"
    "<body><div id=\"content\">%@</div></body> \n"
    "</html>",@"宋体",20.0,news.content];

    contentView.delegate = self;
    contentView.scalesPageToFit = YES;
    [contentView setOpaque:NO];
    [contentView setBackgroundColor:[UIColor clearColor]];
    [contentView loadHTMLString:text baseURL:nil];
    */

    /*
    [lblContent setText:text];
    [lblContent setFont:[UIFont systemFontOfSize:16]];
    [lblContent setNumberOfLines:0];
    CGSize contentSize = [text sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:CGSizeMake(300, 9999) lineBreakMode:lblContent.lineBreakMode];
    [lblContent sizeToFit];
    [lblContent setFrame:CGRectMake(10, startYLoc+10, 300, contentSize.height)];

    startYLoc += contentSize.height + 20;
    */

    //[self.detailScroll setContentSize:CGSizeMake(320, startYLoc)];
     /* 获取webview的高度
    CGSize actualSize = [webView sizeThatFits:CGSizeZero];
    CGRect contentFrame = webView.frame;
    contentFrame.size.height = actualSize.height;
    detailScroll.contentSize = CGSizeMake(320, contentFrame.size.height+60.0);
    webView.frame = contentFrame;
    */
    //CGSize actualSize = [webView sizeThatFits:CGSizeZero];
    //[contentView sizeToFit];
    /*
    if(webView != contentView)
    return;

    float height;
    NSString *heightString = [contentView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"content\").offsetHeight;"];
    NSLog(@"HeightString:%@",heightString);
    height = [heightString floatValue];
    contentView.frame = CGRectMake(contentView.frame.origin.x, contentView.frame.origin.y, 310, height);
    NSLog(@"height :%f", height);
    height = contentView.frame.origin.y + height;


    [detailScroll setContentSize:CGSizeMake(320, height)];

    NSLog(@"ScrollView height :%f",detailScroll.frame.size.height);

    //[self.detailScroll setContentSize:CGSizeMake(320,[heightString intValue])];
    //CGRect WebViewFrame = contentView.frame;
    //[contentView setFrame:CGRectMake(WebViewFrame.origin.x, WebViewFrame.origin.y, 310, [heightString intValue])];
    //contentView.frame = CGRectMake(contentView.frame.origin.x, contentView.frame.origin.y, contentView.frame.size.width,actualHeight);
    //NSLog(@"ContentView'height:%@",contentView.frame.size.height);
    //[self.detailScroll setContentSize:CGSizeMake(320, contentView.frame.size.height)];
    //actualHeight = contentView.frame.origin.y + actualHeight +70;
    //detailScroll.contentSize = CGSizeMake(320, actualHeight+20);
    */

    正则表达式,去除html

    //NSString *text = [news.content stringByReplacingOccurrencesOfRegex:@"<[^>]+>" withString:@" "];

  • 相关阅读:
    sqlHelp.java
    IIS7.0 检测到在集成的托管管道模式下不适用的ASP.NET设置 的解决方法
    [转]安装程序在安装此软件包时遇到一个错误,这可能表示此软件包有错。错误码是29506
    单表中的sql语句
    网页::::无法访问请求的页面,因为该页的相关配置数据无效。
    <authentication mode="Windows"/>
    无法从传输连接中读取数据: 远程主机强迫关闭了一个现有的连接。这个错误很难判断错在哪里,刚开……
    [转] css实现透明度(兼容IE6、IE7、Firefox2.0)
    企业微信机器人消息发送
    阴阳历自动转换工具函数
  • 原文地址:https://www.cnblogs.com/dm521/p/2281018.html
Copyright © 2011-2022 走看看