mirror of
https://github.com/zhigang1992/CCHLinkTextView.git
synced 2026-03-29 17:08:06 +08:00
Use standard gesture recognizers and add more delegate methods
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
623AC49518C11BAD000962A0 /* CCHLinkTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 623AC49418C11BAD000962A0 /* CCHLinkTextView.m */; };
|
||||
626F837918C75FBC004FEABB /* CCHLinkTextViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 626F837818C75FBC004FEABB /* CCHLinkTextViewTests.m */; };
|
||||
629350BF18C8841B000BFBA5 /* CCHLinkGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 629350BE18C8841B000BFBA5 /* CCHLinkGestureRecognizer.m */; };
|
||||
629350C118C89619000BFBA5 /* CCHLinkGestureRecognizerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 629350C018C89619000BFBA5 /* CCHLinkGestureRecognizerTests.m */; };
|
||||
62F55CC118C1180200A7E1CC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F55CC018C1180200A7E1CC /* Foundation.framework */; };
|
||||
62F55CC318C1180200A7E1CC /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F55CC218C1180200A7E1CC /* CoreGraphics.framework */; };
|
||||
62F55CC518C1180200A7E1CC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F55CC418C1180200A7E1CC /* UIKit.framework */; };
|
||||
@@ -41,9 +39,6 @@
|
||||
623AC49418C11BAD000962A0 /* CCHLinkTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCHLinkTextView.m; sourceTree = "<group>"; };
|
||||
623AC49618C11EAA000962A0 /* CCHLinkTextViewDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCHLinkTextViewDelegate.h; sourceTree = "<group>"; };
|
||||
626F837818C75FBC004FEABB /* CCHLinkTextViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCHLinkTextViewTests.m; sourceTree = "<group>"; };
|
||||
629350BD18C8841B000BFBA5 /* CCHLinkGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCHLinkGestureRecognizer.h; sourceTree = "<group>"; };
|
||||
629350BE18C8841B000BFBA5 /* CCHLinkGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCHLinkGestureRecognizer.m; sourceTree = "<group>"; };
|
||||
629350C018C89619000BFBA5 /* CCHLinkGestureRecognizerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCHLinkGestureRecognizerTests.m; sourceTree = "<group>"; };
|
||||
62F55CBD18C1180200A7E1CC /* CCHLinkTextView Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CCHLinkTextView Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
62F55CC018C1180200A7E1CC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
62F55CC218C1180200A7E1CC /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
@@ -94,8 +89,6 @@
|
||||
623AC49318C11BAD000962A0 /* CCHLinkTextView.h */,
|
||||
623AC49418C11BAD000962A0 /* CCHLinkTextView.m */,
|
||||
623AC49618C11EAA000962A0 /* CCHLinkTextViewDelegate.h */,
|
||||
629350BD18C8841B000BFBA5 /* CCHLinkGestureRecognizer.h */,
|
||||
629350BE18C8841B000BFBA5 /* CCHLinkGestureRecognizer.m */,
|
||||
);
|
||||
name = CCHLinkTextView;
|
||||
path = ../CCHLinkTextView;
|
||||
@@ -161,7 +154,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
626F837818C75FBC004FEABB /* CCHLinkTextViewTests.m */,
|
||||
629350C018C89619000BFBA5 /* CCHLinkGestureRecognizerTests.m */,
|
||||
62F55CE618C1180200A7E1CC /* Supporting Files */,
|
||||
);
|
||||
path = "CCHLinkTextView ExampleTests";
|
||||
@@ -276,7 +268,6 @@
|
||||
623AC49518C11BAD000962A0 /* CCHLinkTextView.m in Sources */,
|
||||
62F55CD718C1180200A7E1CC /* ViewController.m in Sources */,
|
||||
62F55CD118C1180200A7E1CC /* AppDelegate.m in Sources */,
|
||||
629350BF18C8841B000BFBA5 /* CCHLinkGestureRecognizer.m in Sources */,
|
||||
62F55CCD18C1180200A7E1CC /* main.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -285,7 +276,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
629350C118C89619000BFBA5 /* CCHLinkGestureRecognizerTests.m in Sources */,
|
||||
626F837918C75FBC004FEABB /* CCHLinkTextViewTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
<sections>
|
||||
<tableViewSection id="SDS-29-0zJ">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="220" id="k0Y-Uy-Ha8">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="220"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="236" id="k0Y-Uy-Ha8">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="236"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="k0Y-Uy-Ha8" id="k3z-LV-UTX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="219"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="235"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VxQ-Cq-ZfU" customClass="CCHLinkTextView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="219"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="235"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
@@ -43,7 +43,7 @@
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="hqF-Qu-rCj">
|
||||
<rect key="frame" x="0.0" y="284" width="320" height="100"/>
|
||||
<rect key="frame" x="0.0" y="300" width="320" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hqF-Qu-rCj" id="awO-l1-7yb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="99"/>
|
||||
@@ -51,7 +51,7 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="FN3-2m-g6F">
|
||||
<rect key="frame" x="0.0" y="384" width="320" height="100"/>
|
||||
<rect key="frame" x="0.0" y="400" width="320" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="FN3-2m-g6F" id="brC-4L-tC9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="99"/>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// Data detectors
|
||||
|
||||
self.storyboardTextView.editable = NO;
|
||||
// self.storyboardTextView.selectable = NO;
|
||||
self.storyboardTextView.selectable = NO;
|
||||
|
||||
[self.storyboardTextView addLinkForRange:NSMakeRange(0, 10)];
|
||||
[self.storyboardTextView addLinkForRange:NSMakeRange(100, 5)];
|
||||
@@ -52,14 +52,25 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)linkTextViewDidTap:(CCHLinkTextView *)linkTextView
|
||||
{
|
||||
[self performSegueWithIdentifier:@"tableViewToDetail" sender:self];
|
||||
}
|
||||
|
||||
- (void)linkTextView:(CCHLinkTextView *)linkTextView didTapLinkAtCharacterIndex:(NSUInteger)characterIndex
|
||||
{
|
||||
NSLog(@"Link tapped");
|
||||
}
|
||||
|
||||
- (void)linkTextViewDidTap:(CCHLinkTextView *)linkTextView
|
||||
{
|
||||
NSLog(@"Tap");
|
||||
[self performSegueWithIdentifier:@"tableViewToDetail" sender:self];
|
||||
}
|
||||
|
||||
- (void)linkTextView:(CCHLinkTextView *)linkTextView didLongPressLinkAtCharacterIndex:(NSUInteger)characterIndex
|
||||
{
|
||||
NSLog(@"Link long pressed");
|
||||
}
|
||||
|
||||
- (void)linkTextViewDidLongPress:(CCHLinkTextView *)linkTextView
|
||||
{
|
||||
NSLog(@"Long press");
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
//
|
||||
// CCHLinkGestureRecognizerTests.m
|
||||
// CCHLinkTextView Example
|
||||
//
|
||||
// Created by Hoefele, Claus on 06.03.14.
|
||||
// Copyright (c) 2014 Claus Höfele. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CCHLinkGestureRecognizer.h"
|
||||
|
||||
#import <UIKit/UIGestureRecognizerSubclass.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface CCHLinkGestureRecognizerTests : XCTestCase
|
||||
|
||||
@property (nonatomic, strong) CCHLinkGestureRecognizer *linkGestureRecognizer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CCHLinkGestureRecognizerTests
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
self.linkGestureRecognizer = [[CCHLinkGestureRecognizer alloc] init];
|
||||
}
|
||||
|
||||
- (void)testStateEnded
|
||||
{
|
||||
UITouch *touch = [[UITouch alloc] init];
|
||||
NSSet *touches = [NSSet setWithObject:touch];
|
||||
|
||||
[self.linkGestureRecognizer touchesBegan:touches withEvent:nil];
|
||||
XCTAssertEqual(self.linkGestureRecognizer.state, UIGestureRecognizerStateBegan);
|
||||
|
||||
[self.linkGestureRecognizer touchesMoved:touches withEvent:nil];
|
||||
XCTAssertEqual(self.linkGestureRecognizer.state, UIGestureRecognizerStateBegan);
|
||||
|
||||
[self.linkGestureRecognizer touchesEnded:touches withEvent:nil];
|
||||
XCTAssertEqual(self.linkGestureRecognizer.state, UIGestureRecognizerStateEnded);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user