remove actions from mflabel

This commit is contained in:
panxi 2019-04-03 12:21:31 -04:00
parent 1f83778680
commit 7d7284bd8d
2 changed files with 0 additions and 26 deletions

View File

@ -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;

View File

@ -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<UITouch *> *)touches withEvent:(UIEvent *)event {
NSDictionary *actionMap = [self areTouchesInActionString:touches];
if (actionMap) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:nil delegate:nil];
}
}
- (NSDictionary *)areTouchesInActionString:(NSSet<UITouch *> *)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