UIWebView 里设置Text的自定义高度
2011-12-08 17:08
239 查看
/*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:@" "];
相关文章推荐
- 安卓自定义View----实现TextView可设置drawable宽高度
- Android自定义TextView 自定义设置圆角背景色
- andriod 动态设置TextView 和 RelativeLayou 高度
- 动态设置TextView的高度,就是点击收起和展示更多的效果
- 设置textView根据输入的文字自动增加高度
- Andriod自定义View一:TextView可设置宽高
- 设置UIWebView为自定义UIScrollViewDelegate代理冲突问题
- 自定义TextView实现设置drawable图片大小
- 高度自定义TextView 绝对满足你
- 【android】TextView 自定义颜色设置
- 【swift,oc】ios开发中巧用自动布局设置自定义cell的高度
- 自定义TextView,设置Drawable图标居中显示
- Android 自定义view-如何设置TextView drawableLeft 图片大小?
- 动态设置TextView的高度
- android自定义ListView高度设置无效
- iOS-自定义TextView的方法,可以设置占位文字(placeholder)又可滚动
- AlertDialog设置自定义高度
- android开发之自定义TextView设置字间距以及通过TextView控件属性设置行间距
- Android根据所设置的textSize获取字体高度和设置行高
- android EditText设置自定义边框后光标被遮挡