Permalink
Browse files

Fixes -layoutSubviewsInRect: so DTDictationPlaceholderView is inserte…

…d for DTDictationPlaceholderTextAttachment even when the textDelegate property has not be set and/or when various delegate methods have not been implemented.
  • Loading branch information...
1 parent bba9959 commit e7101c4cab27695addf06dacb6ff165611567b37 @leehericks leehericks committed Apr 2, 2013
Showing with 41 additions and 45 deletions.
  1. +41 −45 Core/Source/DTAttributedTextContentView.m
@@ -259,60 +259,56 @@ - (void)layoutSubviewsInRect:(CGRect)rect
continue;
}
- if (_delegateFlags.delegateSupportsCustomViewsForAttachments || _delegateFlags.delegateSupportsGenericCustomViews)
+ if (attachment)
{
- if (attachment)
+ indexKey = [NSNumber numberWithInteger:[attachment hash]];
+ UIView *existingAttachmentView = [self.customViewsForAttachmentsIndex objectForKey:indexKey];
+
+ if (existingAttachmentView)
{
- indexKey = [NSNumber numberWithInteger:[attachment hash]];
+ //dispatch_sync(dispatch_get_main_queue(), ^{
+ existingAttachmentView.hidden = NO;
+ existingAttachmentView.frame = frameForSubview;
+
+ existingAttachmentView.alpha = 1;
+
+ [existingAttachmentView setNeedsLayout];
+ [existingAttachmentView setNeedsDisplay];
+ //});
- UIView *existingAttachmentView = [self.customViewsForAttachmentsIndex objectForKey:indexKey];
+ linkURL = nil; // prevent adding link button on top of image view
+ }
+ else
+ {
+ UIView *newCustomAttachmentView = nil;
- if (existingAttachmentView)
+ if ([attachment isKindOfClass:[DTDictationPlaceholderTextAttachment class]])
{
- //dispatch_sync(dispatch_get_main_queue(), ^{
- existingAttachmentView.hidden = NO;
- existingAttachmentView.frame = frameForSubview;
-
- existingAttachmentView.alpha = 1;
-
- [existingAttachmentView setNeedsLayout];
- [existingAttachmentView setNeedsDisplay];
- //});
-
- linkURL = nil; // prevent adding link button on top of image view
+ newCustomAttachmentView = [DTDictationPlaceholderView placeholderView];
+ newCustomAttachmentView.frame = frameForSubview; // set fixed frame
}
- else
+ else if (_delegateFlags.delegateSupportsCustomViewsForAttachments)
{
- UIView *newCustomAttachmentView = nil;
-
- if ([attachment isKindOfClass:[DTDictationPlaceholderTextAttachment class]])
- {
- newCustomAttachmentView = [DTDictationPlaceholderView placeholderView];
- newCustomAttachmentView.frame = frameForSubview; // set fixed frame
- }
- else if (_delegateFlags.delegateSupportsCustomViewsForAttachments)
- {
- newCustomAttachmentView = [_delegate attributedTextContentView:self viewForAttachment:attachment frame:frameForSubview];
- }
- else if (_delegateFlags.delegateSupportsGenericCustomViews)
- {
- NSAttributedString *string = [layoutString attributedSubstringFromRange:runRange];
- newCustomAttachmentView = [_delegate attributedTextContentView:self viewForAttributedString:string frame:frameForSubview];
- }
-
+ newCustomAttachmentView = [_delegate attributedTextContentView:self viewForAttachment:attachment frame:frameForSubview];
+ }
+ else if (_delegateFlags.delegateSupportsGenericCustomViews)
+ {
+ NSAttributedString *string = [layoutString attributedSubstringFromRange:runRange];
+ newCustomAttachmentView = [_delegate attributedTextContentView:self viewForAttributedString:string frame:frameForSubview];
+ }
+
+ if (newCustomAttachmentView)
+ {
+ // delegate responsible to set frame
if (newCustomAttachmentView)
{
- // delegate responsible to set frame
- if (newCustomAttachmentView)
- {
- newCustomAttachmentView.tag = [indexKey integerValue];
- [self addSubview:newCustomAttachmentView];
-
- [self.customViews addObject:newCustomAttachmentView];
- [self.customViewsForAttachmentsIndex setObject:newCustomAttachmentView forKey:indexKey];
-
- linkURL = nil; // prevent adding link button on top of image view
- }
+ newCustomAttachmentView.tag = [indexKey integerValue];
+ [self addSubview:newCustomAttachmentView];
+
+ [self.customViews addObject:newCustomAttachmentView];
+ [self.customViewsForAttachmentsIndex setObject:newCustomAttachmentView forKey:indexKey];
+
+ linkURL = nil; // prevent adding link button on top of image view
}
}
}

0 comments on commit e7101c4

Please sign in to comment.