Git Product home page Git Product logo

yytext's Issues

如何优雅的添加多个textparse

目前好像只能拥有一个textparse
这样的话就需要将许多不同的解析内容全部写到一起,比如:一个textview需要解析自定义emoji也需要解析@xxx
能不能自己写了一个@xxx解析然和与原来的YYTextSimpleEmoticonParser进行合并使用呢?

关于TextBinding自定义

想把邮箱替换为 @联系人 这种样式的字符串,删除的时候直接删除掉该字符串,但是怎么写正则都不起作用,求教这个正则该怎么写,多谢!!!

// NSString *pattern = @"[-_a-zA-Z@.]+[ ,\n]";
NSString *pattern = @"^[@]+[ ,\n]";

How to interact with the custom `UIView` attachment?

Thanks for this great library! In the README example, I found the following codes:

// UIView attachment
UISwitch *switcher = [UISwitch new];
[switcher sizeToFit];
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:switcher contentMode:UIViewContentModeBottom attachmentSize:switcher.frame.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];

However, the UISwitch is not selectable. How to enable selection of the UISwitch (or other element like UITextField)?

YYText sizeThatFits 异常

使用原生 UITextView重写 layoutSubviews方法时调用sizeThatFits获取内容高度以适配 cell,改用了 YYText 后获取的高度始终为0

swift 中使用pod方式引用不到YYImage

具体报错如下

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_YYAnimatedImageView", referenced from:
      objc-class-ref in NSAttributedString+YYText.o
      objc-class-ref in YYTextView.o
  "_OBJC_CLASS_$_YYImage", referenced from:
      objc-class-ref in UIPasteboard+YYText.o
      objc-class-ref in YYTextView.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

正则表达式匹配有bug

如果text是预先赋值进入的,那渲染就没有问题

但是在后续手动输入一个匹配项之后,所有的字符都被认为是匹配的

好像是effectiveRange取区间有问题

e4bd1e10-65d2-4435-a36b-3e9bcbeb313e

Found a weird performance of YYTextView when it's contentEdge was (0, 0, 0, 0)

Simply creat a YYTextView:

    self.automaticallyAdjustsScrollViewInsets = NO;
    YYTextView *textView = [[YYTextView alloc]initWithFrame:CGRectMake(0, 20, self.view.width, 100)];
    textView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
    textView.text = @"This is test text";
    textView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.view addSubview:textView];

Run app and it looks like:
Uploading 2.png…
Uploading 2.png…

(Sorry failed to upload a screenShot, the text ("this is a test text") can't be seen in textView, and after I type some word, still nothing can be seen including the cursor)

Then I change edgeInset.top to 0.5 and run agin, YYTextView look normal, it also look fine when edgeInset.top was -0.5.
But when edgeInset.top was 0, seems everything just went wrong.
I found you asways set the contentEdge to (64, 0 , 0 , 0) in the Demo, was the contentEdge's top just can't be 0? Or am I miss something?

你好,引用报错问题。

你好,我在使用你的YYText框架练习的时候,当我模仿YYTextDemo里边的YYTextAttachmentExample,有qq几个动画,他们使用的是YYImage,每次我引用YYImage,就报错。找不到什么问题,没有重复的YYImageCoder文件名,这文件也没有被链接2次。把YYImage删除后又添加还是不行。Other Linker Flags下边什么都没有。另外这种报错每次遇到都很麻烦,不知道您怎么解决的呢?我只知道看看有没文件名重复,build Phases有没有链接重复,别的都不确定
日志:
Undefined symbols for architecture x86_64:
"_crc32", referenced from:
_yy_png_copy_frame_data_at_index in YYImageCoder.o
-[YYImageEncoder _encodeAPNG] in YYImageCoder.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

YYTextView 问题

编辑过程中, 会遇到下面Crash.
Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'
Code:
- (NSDictionary *)attributesAtIndex:(NSUInteger)index { if (self.length > 0 && index == self.length) index--; return [self attributesAtIndex:index effectiveRange:NULL]; }

YYLabel bug

NSMutableAttributedString *text = [NSMutableAttributedString new];
UIFont *font = [UIFont boldSystemFontOfSize:16];
for (int i = 0; i < tags.count; i++) {
    NSString *tag = tags[i];
    UIColor *tagStrokeColor = UIColorHex(818e91);
    NSMutableAttributedString *tagText = [[NSMutableAttributedString alloc] initWithString:tag];
    [tagText yy_insertString:@"   " atIndex:0];
    [tagText yy_appendString:@"   "];
    tagText.yy_font = font;
    tagText.yy_color = tagStrokeColor;

    YYTextBorder *border = [YYTextBorder new];
    border.strokeWidth = 1.2f;
    border.strokeColor = tagStrokeColor;
    border.fillColor = [UIColor clearColor];
    border.cornerRadius = 100; // a huge value
    border.lineJoin = kCGLineJoinBevel;

    border.insets = UIEdgeInsetsMake(1.5, -6, 0, -6);
    [tagText yy_setTextBackgroundBorder:border range:[tagText.string rangeOfString:tag]];

    [text appendAttributedString:tagText];
}
text.yy_lineSpacing = 0;
text.yy_lineBreakMode = NSLineBreakByCharWrapping;

我的YYLabel 是写在cell上得并且自动布局强制大小的,当我的内容加起来刚好1行以内,就不会报错,而内容大于1行时,YYLabel库里面就直接crash了。

关于基本UILable的用法

我的cell并不是需要大量富文本,所以我就直接用YYLbel的基本用法,只是让它异步绘制。代码如下
_requir=[YYLabel new];
_requir.displaysAsynchronously=YES;
_requir.frame=CGRectMake(110, 35, 120, 14);
_requir.backgroundColor=[UIColor redColor];
[self.contentView addSubview:_requir];
_requir.font=kSystemFont(14);

    _stock=[[YYLabel alloc]init];
    _stock.displaysAsynchronously=YES;
    _stock.backgroundColor=[UIColor redColor];
    _stock.frame=CGRectMake(110, 60, 120, 14);
    [self.contentView addSubview:_stock];
    _stock.font=kSystemFont(14);

然后我在setModel的方法里
_requir.text=[NSString stringWithFormat:@"兑换条件:%@",model.convertCondition];
_stock.text=[NSString stringWithFormat:@"剩余:%d份",(int)model.residueNumber];

但是结果却是
img_0252

只有把_stock的高加3也就是17才能显示出来。这是什么情况,我有点摸不着头脑。希望表达清楚了,望解答。

不支持 preferedStatusBarStyle

创建一个YYTextView() 状态栏就会变成defualt
为什么呢?

我使用的

    override func preferredStatusBarStyle() -> UIStatusBarStyle {

        return UIStatusBarStyle.LightContent

    }

来控制状态栏的。

行距问题疑问

YYText 非常棒,我已经扔掉了 TTTAttributedLabel :D
有个疑问,在文字段落时,行距有时候并没有保持一致,原因不明,见截图:
img_7582

这是一段很均匀的纯文本(无 emoji 和 Attachment,也没有任何 highlight 和 binding)
仔细看一下会发现,倒数第六行的行距和其他行不同(「。第二,科创版推出...」这一行)

具体原因不明,代码片段:

- (YYLabel *)textLabel
{
   if (!textLabel) {
       self.textLabel = [[YYLabel alloc] initWithFrame:CGRectZero];
       self.textLabel.userInteractionEnabled = YES;
       self.textLabel.font = [UIFont systemFontOfSize:kEspressoDescriptionTextFontSize];
       self.textLabel.textColor = [UIColor darkGrayColor];
       self.textLabel.lineBreakMode = NSLineBreakByCharWrapping;
       self.textLabel.textVerticalAlignment = YYTextVerticalAlignmentCenter;
       self.textLabel.numberOfLines = 0;
       self.textLabel.displaysAsynchronously = YES;
       [bubbleView addSubview:self.textLabel];
    }
    return textLabel;
}
- (YYTextLayout *)textLayoutForMessageContent:(NSString *)content font:(UIFont *)font textWidth:(CGFloat)maxWidth {
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:content];
    text.yy_font = font;
    text.yy_color = [UIColor darkGrayColor];
    text.yy_lineSpacing = kTextLineSpacing;
    text.yy_lineBreakMode = NSLineBreakByCharWrapping;

    // 解析超链接
    [text enumerateTextParser:AKCTextMessageCheckingTypeURL];

    // 解析电话号码
    [text enumerateTextParser:AKCTextMessageCheckingTypePhoneNum];

    // 解析邮箱地址
    [text enumerateTextParser:AKCTextMessageCheckingTypeEmail];

    // 解析表情
    [text enumerateTextParser:AKCTextMessageCheckingTypeFace];

    YYTextContainer *container = [YYTextContainer new];
    container.size = CGSizeMake(maxWidth, CGFLOAT_MAX);

    YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];

    return layout;
}
    YYTextLayout *layout = [self textLayoutForMessageContent:msgModel.message_content font:[UIFont systemFontOfSize:16.f] textWidth:maxTextWidth];

    width = layout.textBoundingSize.width;
    height = layout.textBoundingSize.height;

    self.textLabel.frame = CGRectMake(kLeftBubbleTextLeftInset,
                                            kBubbleTextTopInset,
                                            width,
                                            height);
    self.textLabel.textLayout = layout;

根据内容改变容器size 单行时会跳动, 并且回车换行没有计算到高度里。

  • (void)textViewDidChange:(YYTextView *)textView {

    NSAttributedString *text = textView.attributedText;
    if ([textView.text isEqualToString:@""]) {
    text = textView.placeholderAttributedText;
    }

    CGSize size = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
    YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:text];

    CGSize newSize = CGSizeMake(layout.textBoundingSize.width, layout.textBoundingSize.height);

    NSLog(@"layout.textBoundingSize :%@",NSStringFromCGSize(layout.textBoundingSize));
    NSLog(@"self.textView.contentSize :%@",NSStringFromCGSize(self.textView.contentSize));

    self.textView.size = newSize;
    self.textView.contentSize = newSize;

}

log:
2015-11-26 17:48:49.218 testTextView[8110:1979479] layout.textBoundingSize :{249, 23}
2015-11-26 17:48:49.218 testTextView[8110:1979479] self.textView.contentSize :{240, 50}

YYLabel显示不出的问题

我使用的Masonry布局,在ios8.4下遇到了如下问题
1.当要显示的字体较大时超过了要显示的范围,YYLabel什么都不显示
2.当添加了文本解析器后,必须减小字体,文字和表情才能显示出来
image
没有使用表情解析时能够显示出来
image
使用了表情解析显示不出来
image
当把字体缩小成13后就能显示了
image
3.YYLabel的textVerticalAlignment属性不起作用

selectedRange不准确

您好。在这个代理方法里面- (void)textViewDidChangeSelection:(YYTextView *)textView,返回回来的selectedRange不准确,具体的说是长按后处于选定状态下,返回的range.length为0,但是按一下空白区域,让蓝色选定状态消失,这次返回的range的结果是正确的,length为选定的文本的长度。

刚刚又试了一下,这个range始终返回的是上一次操作的range

YYTextView设置的属性,在输入文字时会被清除

调试时发现:

  • (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange {
    [self _updateIfNeeded];
    [self _endTouchTracking];
    [self _hideMenu];

    if (!NSEqualRanges(_lastTypeRange, _selectedTextRange.asRange)) {
    [self _saveToUndoStack];
    [self _resetRedoStack];
    }

    BOOL needApplyHolderAttribute = NO;
    if (_innerText.length > 0) {
    [self _updateAttributesHolder]; // 这儿,会将设置的属性重置为前面文字的属性
    } else {
    needApplyHolderAttribute = YES;
    }

这样会导致手动设置的属性被重置,不知道是不是故意这样设计的?

在TableViewCell中添加 YYAnimatedImageView 上下滚动时,有时图标会不显示

添加的代码如下:

    YYImage *image = [YYImage imageNamed:imageName];
    YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 2, 38, 16)];
    label.text = text;
    label.font = [UIFont systemFontOfSize:12];
    label.textColor = color;
    [imageView addSubview:label];

    NSMutableAttributedString *imgText = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeCenter attachmentSize:size alignToFont:[UIFont systemFontOfSize:12] alignment:YYTextVerticalAlignmentBottom];

    [_attrText appendAttributedString:imgText];

YYLabel使用问题

使用new / alloc] init] 创建对象,再设置frame属性, YYLabel显示
而直接使用 alloc] initWithFrame 创建对象, YYLabel无法显示

当文本含有表情时,YYTextLayout计算出来的高度是不正确的

应该是把表情符号当做文本处理后进行高度计算了,
如文本:您haidf阿打发士大夫撒地方发的啥方[f024t]法发达范德萨法撒旦法地方
[f024t] 代表一个表情

NSMutableAttributedString *text = [[NSMutableAttributedString alloc]initWithString:txt];
text.yy_font=[UIFont systemFontOfSize:17.0f];

YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new];
modifier.fixedLineHeight = 22.0f;

YYTextContainer *container = [YYTextContainer new];
container.size =  CGSizeMake([[UIScreen mainScreen] bounds].size.width * 0.7f-50, CGFLOAT_MAX);
container.linePositionModifier = modifier;

YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text ];

实质显示只有3行,计算出来是4行。屏幕宽度320

请问两个问题

1、插入图片后,字体会变的很小,好像是一个默认字体。
2、如何获取我插入的附件数组?比如我要输入很多文字,很多图片,最后我要做一个“提交文章”的功能,这些图片我要上传到服务器上。
3、输入很多文字的时候,内存还是会变得很大,有被系统杀掉的风险。

YYTextView 问题

YYTextContainer *newContainer = _innerContainer.mutableCopy;
这快会Crash.

Log信息:
reason: '-[YYTextContainer mutableCopyWithZone:]: unrecognized selector sent to instance 0x7ff7da64b690'

暂时改为Copy可以用.

Missing last line sometimes with emoticon attachment.

When set label's size as textBoundingSize after YYTextLayout, it may cause missing last line when process layoutWithContainer:text:range in display task.

In my code, I've custom a YYLabel contains emoticons, it has a preferred width 232, when use YYTextLayout to calculate size, it returns line count 5 and CGSize(228, 116).

The I set the label's size as (228, 116), when it display, layoutWithContainer:text:range result line count 4.

I can fix this in my own code by keep the label width as preferred width, but it would easy trapped when someone use the textBoundingSize.

use cocoapods build error

pod 'YYWebImage'
pod 'YYKit'
pod 'YYText'

build error :
1.Redefinition of 'YYTextVerticalAlignment'
2.Duplicate interface definition for class 'YYTextRunDelegate'
3.Duplicate interface definition for class 'YYAnimatedImageView'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.