Skip to content

Commit b86a3e6

Browse files
committed
add some features
1 parent 56e3057 commit b86a3e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+142
-140
lines changed

1.png

-66.1 KB
Binary file not shown.

2.png

-64.6 KB
Binary file not shown.

3.png

-63.8 KB
Binary file not shown.

DDRichText.xcodeproj/project.pbxproj

+110-118
Large diffs are not rendered by default.

DDRichText/Base.lproj/Main.storyboard

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</viewController>
2222
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2323
</objects>
24-
<point key="canvasLocation" x="1120" y="311"/>
24+
<point key="canvasLocation" x="976" y="337"/>
2525
</scene>
2626
<!--Navigation Controller-->
2727
<scene sceneID="UAz-xA-WhP">
@@ -39,7 +39,7 @@
3939
</navigationController>
4040
<placeholder placeholderIdentifier="IBFirstResponder" id="94z-1z-D3Q" userLabel="First Responder" sceneMemberID="firstResponder"/>
4141
</objects>
42-
<point key="canvasLocation" x="953" y="285"/>
42+
<point key="canvasLocation" x="235" y="337"/>
4343
</scene>
4444
</scenes>
4545
</document>

DDRichText/TestViewController.m

+11-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "TestViewController.h"
10+
#import "UIImageView+WebCache.h"
1011

1112
@interface TestViewController ()
1213

@@ -20,14 +21,16 @@ - (void)viewDidLoad {
2021

2122
self.title = @"DDRichText";
2223

24+
25+
//图片支持网络异步加载
2326
NSMutableArray *_imageDataSource = [NSMutableArray arrayWithCapacity:0];
24-
[_imageDataSource addObject:@"1.png"];
25-
[_imageDataSource addObject:@"2.png"];
26-
[_imageDataSource addObject:@"3.png"];
27-
[_imageDataSource addObject:@"3.png"];
28-
[_imageDataSource addObject:@"2.png"];
29-
[_imageDataSource addObject:@"1.png"];
30-
[_imageDataSource addObject:@"1.png"];
27+
[_imageDataSource addObject:@"https://octodex.github.com/images/privateinvestocat.jpg"];
28+
[_imageDataSource addObject:@"https://octodex.github.com/images/gracehoppertocat.jpg"];
29+
[_imageDataSource addObject:@"https://octodex.github.com/images/jetpacktocat.png"];
30+
[_imageDataSource addObject:@"https://octodex.github.com/images/minertocat.png"];
31+
[_imageDataSource addObject:@"https://octodex.github.com/images/luchadortocat.png"];
32+
[_imageDataSource addObject:@"https://octodex.github.com/images/saritocat.png"];
33+
[_imageDataSource addObject:@"https://octodex.github.com/images/steroidtocat.png"];
3134

3235
NSMutableArray *_replyDataSource = [[NSMutableArray alloc] init];//回复数据来源
3336
[_replyDataSource addObject:@"@Della:@戴伟来 DDRichText棒棒哒! @daiweilai: @daiweilai @戴伟来:I am Della,这是一个IOS库[em:01:][em:02:][em:03:]"];
@@ -41,12 +44,10 @@ - (void)viewDidLoad {
4144
ymData.replyDataSource = _replyDataSource;
4245
ymData.name = @"David";
4346
ymData.intro = @"2015-2-8";
44-
ymData.headPic = [UIImage imageNamed:@"1.png"];
47+
ymData.headPicURL = @"https://octodex.github.com/images/mummytocat.gif";
4548
[ymDataArray addObject:ymData];
4649
self.delegate = self;
4750
self.dataSource = self;
48-
49-
5051
}
5152

5253
-(NSString *)senderName{

DDRichTextLib/DDRichTextViewController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "YMShowImageView.h"
1111
#import "YMTextData.h"
1212
#import "YMReplyInputView.h"
13-
#import "UIImageView+WebCache.h"
13+
1414

1515
@protocol DDRichTextViewDelegate <NSObject>
1616
@required

DDRichTextLib/DDRichTextViewController.m

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by David on 15/2/6.
66
// Copyright (c) 2015年 tigerwf. All rights reserved.
77
//
8-
8+
#import "UIImageView+WebCache.h"
99
#import "DDRichTextViewController.h"
1010

1111
@interface DDRichTextViewController()<UITableViewDataSource,UITableViewDelegate,cellDelegate,InputDelegate>
@@ -90,7 +90,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
9090
}
9191
}
9292
YMTextData *data = [[self dataSource] dataForRowAtIndex:[indexPath section]];
93-
cell.headerImage.image = data.headPic;
93+
//这句话让头像 支持异步加载
94+
[cell.headerImage sd_setImageWithURL:[NSURL URLWithString:data.headPicURL] placeholderImage:[UIImage imageNamed:@"nilPic.png"]];
95+
// cell.headerImage.image = data.headPic;
9496
cell.nameLbl.text = data.name;
9597
cell.introLbl.text = data.intro;
9698
[cell setYMViewWith:data];
@@ -191,11 +193,13 @@ -(void)didRichTextPress:(NSString *)text index:(NSInteger)index replyIndex:(NSIn
191193

192194
#pragma mark - 图片点击事件回调
193195
- (void)showImageViewWithImageViews:(NSArray *)imageViews byClickWhich:(NSInteger)clickTag{
196+
[[self navigationController] setNavigationBarHidden:YES animated:YES];
194197
UIView *maskview = [[UIView alloc] initWithFrame:self.view.bounds];
195198
maskview.backgroundColor = [UIColor blackColor];
196199
[self.view addSubview:maskview];
197200
YMShowImageView *ymImageV = [[YMShowImageView alloc] initWithFrame:self.view.bounds byClick:clickTag appendArray:imageViews];
198201
[ymImageV show:maskview didFinish:^(){
202+
[[self navigationController] setNavigationBarHidden:NO animated:YES];
199203
[UIView animateWithDuration:0.5f animations:^{
200204
ymImageV.alpha = 0.0f;
201205
maskview.alpha = 0.0f;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

DDRichTextLib/SDWebImage/nilPic.png

9.59 KB

DDRichTextLib/YMShowImageView.m

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "YMShowImageView.h"
10+
#import "UIImageView+WebCache.h"
1011

1112
@implementation YMShowImageView{
1213

@@ -72,8 +73,10 @@ - (void)configScrollViewWith:(NSInteger)clickTag andAppendArray:(NSArray *)appen
7273
imageScrollView.minimumZoomScale = 1;
7374

7475
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
75-
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[appendArray objectAtIndex:i]]];
76-
imageView.image = img;
76+
//这句话让图片支持网络异步加载
77+
[imageView sd_setImageWithURL:[NSURL URLWithString:[appendArray objectAtIndex:i]] placeholderImage:[UIImage imageNamed:@"nilPic.png"]];
78+
// UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[appendArray objectAtIndex:i]]];
79+
// imageView.image = img;
7780
imageView.contentMode = UIViewContentModeScaleAspectFit;
7881
[imageScrollView addSubview:imageView];
7982
[_scrollView addSubview:imageScrollView];

DDRichTextLib/YMTableViewCell.m

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// 2 3 2 2 2 3 1 3 2 1
88

99
#import "YMTableViewCell.h"
10-
10+
#import "UIImageView+WebCache.h"
1111
#import "ContantHead.h"
1212
#import "YMTapGestureRecongnizer.h"
1313

@@ -36,7 +36,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3636
self.selectionStyle = UITableViewCellSelectionStyleNone;
3737

3838
_headerImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 5, 50, TableHeader)];
39-
_headerImage.backgroundColor = [UIColor blackColor];
39+
_headerImage.backgroundColor = [UIColor clearColor];
4040
_headerImage.userInteractionEnabled = YES;
4141
UIGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didHeadPicAndNamePress)];
4242
[_headerImage addGestureRecognizer:tap1];
@@ -182,7 +182,9 @@ - (void)setYMViewWith:(YMTextData *)ymData{
182182
tap.appendArray = ymData.showImageArray;
183183
image.backgroundColor = [UIColor clearColor];
184184
image.tag = kImageTag + i;
185-
image.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[ymData.showImageArray objectAtIndex:i]]];
185+
// 这句话 让图片 支持网络异步加载图片
186+
[image sd_setImageWithURL:[NSURL URLWithString:[ymData.showImageArray objectAtIndex:i]] placeholderImage:[UIImage imageNamed:@"nilPic.png"]];
187+
// image.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[ymData.showImageArray objectAtIndex:i]]];
186188
[self.contentView addSubview:image];
187189
[_imageArray addObject:image];
188190

DDRichTextLib/YMTextData.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@property (nonatomic,strong) NSMutableArray *defineAttrData;//自行添加 元素为每条回复中的自行添加的range组成的数组 如:第一条回复有(0,2)和(5,2) 第二条为(0,2)。。。。可以为nil
1818
@property (nonatomic,strong) NSMutableArray *replyDataSource;//回复内容数据源(未处理)可以为nil
1919
@property (nonatomic,strong)NSString *name;//发布说说人的姓名 可以为nil
20-
@property (nonatomic,strong)UIImage *headPic;//发布说说人的头像 可以为nil
20+
@property (nonatomic,strong)NSString *headPicURL;//发布说说人的头像 可以为nil 支持网络异步加载
2121
@property (nonatomic,strong)NSString *intro;//可以用来显示简介或者时间 可以为nil
2222

2323

DDRichTextLib/YMTextData.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ - (id)init
3434
_foldOrNot = YES;
3535
_islessLimit = NO;
3636
_name = @"";
37-
_headPic = [UIImage new];
37+
_headPicURL = @"";
3838
_intro = @"";
3939
}
4040
return self;

0 commit comments

Comments
 (0)