From 7d7284bd8d50202a10704a9de24d96b6979f2fcc Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 3 Apr 2019 12:21:31 -0400 Subject: [PATCH] remove actions from mflabel --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 -- MVMCoreUI/Atoms/Views/MFLabel.m | 24 ------------------------ 2 files changed, 26 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 896d1dca..22308465 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -20,8 +20,6 @@ // Set this to use a custom sizing object during updateView instead of the standard. @property (nonatomic, strong, nullable) MFSizeObject *sizeObject; -@property (nonatomic, strong, nullable) NSDictionary *actions; - // Set the font and set to scale - (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index c9d10129..c689e980 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -199,7 +199,6 @@ NSArray *attributes = [json array:@"attributes"]; if (attributes) { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}]; - NSMutableDictionary *actions = [NSMutableDictionary new]; for (NSDictionary *attribute in attributes) { NSNumber *location = [attribute optionalNumberForKey:@"location"]; NSNumber *length = [attribute optionalNumberForKey:@"length"]; @@ -229,14 +228,12 @@ } } else if ([type isEqualToString:@"link"]) { label.userInteractionEnabled = YES; - [actions setObject:attribute forKey:[NSValue valueWithRange:range]]; } } } label.attributedText = attributedString; if ([label isKindOfClass:[MFLabel class]]) { MFLabel *mflabel = (MFLabel *)label; - mflabel.actions = actions; } } @@ -299,25 +296,4 @@ } -#pragma mark - action - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - NSDictionary *actionMap = [self areTouchesInActionString:touches]; - if (actionMap) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:nil delegate:nil]; - } -} - -- (NSDictionary *)areTouchesInActionString:(NSSet *)touches { - CGPoint location = [[touches anyObject] locationInView:self]; - for (NSValue *valueOfRange in self.actions.allKeys) { - NSRange range = [valueOfRange rangeValue]; - CGRect rect = [self boundingRectForCharacterRange:range]; - if (CGRectContainsPoint(rect, location)){ - return [self.actions objectForKey:valueOfRange]; - } - } - return nil; -} - @end