Text attachments and origin fixes #5

merged 2 commits into from Sep 1, 2011


None yet
3 participants

mikeash commented Aug 29, 2011

I added some rudimentary support for text attachments (basically, custom drawing or UIViews embedded in the text). I also fixed up some coordinate transforms which were incorrect for indented text (and were affecting the placement of the attachments in my testing). Both could probably stand to be tested a little more....

Michael Ash added some commits Aug 29, 2011

Michael Ash take into account line X origins when generating rects and otherwise …
…manipulating text coordinates, in order to correctly handle indented text
Michael Ash add support for text attachments d8622cc

devindoty merged commit 2e9f108 into enormego:master Sep 1, 2011

Q1: _attachmentViews in EGOTextView.m seems not been alloc and init. how could the following code work:

NSLog(@"_attachmentViews :%@",_attachmentViews);
for (UIView *view in _attachmentViews) {
    [view removeFromSuperview];
[_attributedString enumerateAttribute: EGOTextAttachmentAttributeName inRange: NSMakeRange(0, [_attributedString length]) options: 0 usingBlock: ^(id value, NSRange range, BOOL *stop) {

    if ([value respondsToSelector: @selector(attachmentView)]) {
        UIView *view = [value attachmentView];
        [_attachmentViews addObject: view];
        NSLog(@"_attachmentViews :%@",_attachmentViews);

        CGRect rect = [self firstRectForNSRange: range];
        rect.size = [view frame].size;
        [view setFrame: rect];
        [self addSubview: view];

Q2: Im using the following code to display an image in EGOTextView. But how could I delete it?

    AttachmentImageViewCell *attachmentCell = [[AttachmentImageViewCell alloc] initWithImage:[UIImage imageNamed:@"aa.png"]];
    attachmentCell.frame = CGRectMake(0, 0, 100, 100);
    NSDictionary *attachmentDict = [NSDictionary dictionaryWithObject:attachmentCell forKey:EGOTextAttachmentAttributeName];

    NSAttributedString *atrStr = [[NSAttributedString alloc] initWithString:@"picture" attributes:attachmentDict];
    self.egoTextView.attributedString = atrStr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment