Commit 718c3a47 authored by 刘俊宏's avatar 刘俊宏

强加换行符号(富文本编辑器)

parent a4710590
...@@ -196,8 +196,12 @@ ...@@ -196,8 +196,12 @@
} }
_htmlStr = @""; _htmlStr = @"";
} }
// [self.textView insertImage:[UIImage imageNamed:@"banner"] atIndex:0];
// [self.textView insertImage:[UIImage imageNamed:@"banner"] atIndex:1];
// [self.textView insertImage:[UIImage imageNamed:@"banner"] atIndex:2];
// [self.textView insertImage:[UIImage imageNamed:@"banner"] atIndex:3];
// [self.textView insertImage:[UIImage imageNamed:@"banner"] atIndex:4];
// [self.textView insertImage:[UIImage imageNamed:@"banner"] atIndex:5];
} }
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
...@@ -275,6 +279,7 @@ ...@@ -275,6 +279,7 @@
TFHpple * doc = [[TFHpple alloc] initWithHTMLData:data]; TFHpple * doc = [[TFHpple alloc] initWithHTMLData:data];
// 搜索XPath寻找标签 // 搜索XPath寻找标签
NSArray *elements = [doc searchWithXPathQuery:@"//p"]; NSArray *elements = [doc searchWithXPathQuery:@"//p"];
for (TFHppleElement * element in elements) { for (TFHppleElement * element in elements) {
NSLog(@"content:%@" , [element content]); NSLog(@"content:%@" , [element content]);
if (content.length == 0) { if (content.length == 0) {
...@@ -286,6 +291,12 @@ ...@@ -286,6 +291,12 @@
content = [NSString stringWithFormat:@"%@\n%@",content,[element content]]; content = [NSString stringWithFormat:@"%@\n%@",content,[element content]];
} }
} }
NSString *tempContent = [element content];
if (tempContent.length == 0 && self.imgIndexArr.count != 0) {
content = [NSString stringWithFormat:@"%@\n",content];
}
TFHppleElement *imgDic = [element firstChildWithTagName:@"img"]; TFHppleElement *imgDic = [element firstChildWithTagName:@"img"];
if (imgDic) { if (imgDic) {
NSString *src = [[imgDic attributes]objectForKey:@"src"]; NSString *src = [[imgDic attributes]objectForKey:@"src"];
......
...@@ -75,8 +75,8 @@ static CGFloat const kVerticalMargin = kVerticalInset + kMargin; ...@@ -75,8 +75,8 @@ static CGFloat const kVerticalMargin = kVerticalInset + kMargin;
- (void)setImage:(UIImage *)image - (void)setImage:(UIImage *)image
{ {
// _image = image; _image = image;
// self.imageView.image = image; self.imageView.image = image;
[self setNeedsDisplay]; [self setNeedsDisplay];
} }
- (void)setImageUrl:(NSString *)imageUrl { - (void)setImageUrl:(NSString *)imageUrl {
...@@ -88,7 +88,7 @@ static CGFloat const kVerticalMargin = kVerticalInset + kMargin; ...@@ -88,7 +88,7 @@ static CGFloat const kVerticalMargin = kVerticalInset + kMargin;
NSLog(@"网络图片大小=%f,%f",size.width,size.height); NSLog(@"网络图片大小=%f,%f",size.width,size.height);
}]; }];
// [self setNeedsDisplay]; [self setNeedsDisplay];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment