From fa9a10c845a8f7dbbe16b73f3c451e1387ad3228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20Ho=CC=88fele?= Date: Fri, 28 Feb 2014 21:25:22 +0100 Subject: [PATCH] Initial prototype with example --- .../project.pbxproj | 494 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../CCHLinkTextView Example/AppDelegate.h | 15 + .../CCHLinkTextView Example/AppDelegate.m | 46 ++ .../Base.lproj/Main.storyboard | 99 ++++ .../CCHLinkTextView Example-Info.plist | 40 ++ .../CCHLinkTextView Example-Prefix.pch | 16 + .../AppIcon.appiconset/Contents.json | 23 + .../LaunchImage.launchimage/Contents.json | 23 + .../CCHLinkTextView Example/ViewController.h | 13 + .../CCHLinkTextView Example/ViewController.m | 38 ++ .../en.lproj/InfoPlist.strings | 2 + .../CCHLinkTextView Example/main.m | 18 + .../CCHLinkTextView ExampleTests-Info.plist | 22 + .../CCHLinkTextView_ExampleTests.m | 34 ++ .../en.lproj/InfoPlist.strings | 2 + CCHLinkTextView/CCHLinkTextView.h | 19 + CCHLinkTextView/CCHLinkTextView.m | 88 ++++ CCHLinkTextView/CCHLinkTextViewDelegate.h | 16 + 19 files changed, 1015 insertions(+) create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.pbxproj create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.h create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.m create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/Base.lproj/Main.storyboard create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Info.plist create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/ViewController.h create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/ViewController.m create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/en.lproj/InfoPlist.strings create mode 100644 CCHLinkTextView Example/CCHLinkTextView Example/main.m create mode 100644 CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView ExampleTests-Info.plist create mode 100644 CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView_ExampleTests.m create mode 100644 CCHLinkTextView Example/CCHLinkTextView ExampleTests/en.lproj/InfoPlist.strings create mode 100644 CCHLinkTextView/CCHLinkTextView.h create mode 100644 CCHLinkTextView/CCHLinkTextView.m create mode 100644 CCHLinkTextView/CCHLinkTextViewDelegate.h diff --git a/CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.pbxproj b/CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2d8beb3 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.pbxproj @@ -0,0 +1,494 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 623AC49518C11BAD000962A0 /* CCHLinkTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 623AC49418C11BAD000962A0 /* CCHLinkTextView.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 */; }; + 62F55CCB18C1180200A7E1CC /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 62F55CC918C1180200A7E1CC /* InfoPlist.strings */; }; + 62F55CCD18C1180200A7E1CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F55CCC18C1180200A7E1CC /* main.m */; }; + 62F55CD118C1180200A7E1CC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F55CD018C1180200A7E1CC /* AppDelegate.m */; }; + 62F55CD418C1180200A7E1CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 62F55CD218C1180200A7E1CC /* Main.storyboard */; }; + 62F55CD718C1180200A7E1CC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F55CD618C1180200A7E1CC /* ViewController.m */; }; + 62F55CD918C1180200A7E1CC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 62F55CD818C1180200A7E1CC /* Images.xcassets */; }; + 62F55CE018C1180200A7E1CC /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F55CDF18C1180200A7E1CC /* XCTest.framework */; }; + 62F55CE118C1180200A7E1CC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F55CC018C1180200A7E1CC /* Foundation.framework */; }; + 62F55CE218C1180200A7E1CC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F55CC418C1180200A7E1CC /* UIKit.framework */; }; + 62F55CEA18C1180200A7E1CC /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 62F55CE818C1180200A7E1CC /* InfoPlist.strings */; }; + 62F55CEC18C1180200A7E1CC /* CCHLinkTextView_ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F55CEB18C1180200A7E1CC /* CCHLinkTextView_ExampleTests.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 62F55CE318C1180200A7E1CC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 62F55CB518C1180200A7E1CC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 62F55CBC18C1180200A7E1CC; + remoteInfo = "CCHLinkTextView Example"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 623AC49318C11BAD000962A0 /* CCHLinkTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCHLinkTextView.h; sourceTree = ""; }; + 623AC49418C11BAD000962A0 /* CCHLinkTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCHLinkTextView.m; sourceTree = ""; }; + 623AC49618C11EAA000962A0 /* CCHLinkTextViewDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCHLinkTextViewDelegate.h; sourceTree = ""; }; + 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; }; + 62F55CC418C1180200A7E1CC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 62F55CC818C1180200A7E1CC /* CCHLinkTextView Example-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CCHLinkTextView Example-Info.plist"; sourceTree = ""; }; + 62F55CCA18C1180200A7E1CC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 62F55CCC18C1180200A7E1CC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 62F55CCE18C1180200A7E1CC /* CCHLinkTextView Example-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CCHLinkTextView Example-Prefix.pch"; sourceTree = ""; }; + 62F55CCF18C1180200A7E1CC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 62F55CD018C1180200A7E1CC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 62F55CD318C1180200A7E1CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 62F55CD518C1180200A7E1CC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 62F55CD618C1180200A7E1CC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 62F55CD818C1180200A7E1CC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 62F55CDE18C1180200A7E1CC /* CCHLinkTextView ExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "CCHLinkTextView ExampleTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 62F55CDF18C1180200A7E1CC /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + 62F55CE718C1180200A7E1CC /* CCHLinkTextView ExampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CCHLinkTextView ExampleTests-Info.plist"; sourceTree = ""; }; + 62F55CE918C1180200A7E1CC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 62F55CEB18C1180200A7E1CC /* CCHLinkTextView_ExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CCHLinkTextView_ExampleTests.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 62F55CBA18C1180200A7E1CC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 62F55CC318C1180200A7E1CC /* CoreGraphics.framework in Frameworks */, + 62F55CC518C1180200A7E1CC /* UIKit.framework in Frameworks */, + 62F55CC118C1180200A7E1CC /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 62F55CDB18C1180200A7E1CC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 62F55CE018C1180200A7E1CC /* XCTest.framework in Frameworks */, + 62F55CE218C1180200A7E1CC /* UIKit.framework in Frameworks */, + 62F55CE118C1180200A7E1CC /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 623AC49218C11B99000962A0 /* CCHLinkTextView */ = { + isa = PBXGroup; + children = ( + 623AC49318C11BAD000962A0 /* CCHLinkTextView.h */, + 623AC49418C11BAD000962A0 /* CCHLinkTextView.m */, + 623AC49618C11EAA000962A0 /* CCHLinkTextViewDelegate.h */, + ); + name = CCHLinkTextView; + path = ../CCHLinkTextView; + sourceTree = ""; + }; + 62F55CB418C1180200A7E1CC = { + isa = PBXGroup; + children = ( + 623AC49218C11B99000962A0 /* CCHLinkTextView */, + 62F55CC618C1180200A7E1CC /* CCHLinkTextView Example */, + 62F55CE518C1180200A7E1CC /* CCHLinkTextView ExampleTests */, + 62F55CBF18C1180200A7E1CC /* Frameworks */, + 62F55CBE18C1180200A7E1CC /* Products */, + ); + sourceTree = ""; + }; + 62F55CBE18C1180200A7E1CC /* Products */ = { + isa = PBXGroup; + children = ( + 62F55CBD18C1180200A7E1CC /* CCHLinkTextView Example.app */, + 62F55CDE18C1180200A7E1CC /* CCHLinkTextView ExampleTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 62F55CBF18C1180200A7E1CC /* Frameworks */ = { + isa = PBXGroup; + children = ( + 62F55CC018C1180200A7E1CC /* Foundation.framework */, + 62F55CC218C1180200A7E1CC /* CoreGraphics.framework */, + 62F55CC418C1180200A7E1CC /* UIKit.framework */, + 62F55CDF18C1180200A7E1CC /* XCTest.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 62F55CC618C1180200A7E1CC /* CCHLinkTextView Example */ = { + isa = PBXGroup; + children = ( + 62F55CCF18C1180200A7E1CC /* AppDelegate.h */, + 62F55CD018C1180200A7E1CC /* AppDelegate.m */, + 62F55CD218C1180200A7E1CC /* Main.storyboard */, + 62F55CD518C1180200A7E1CC /* ViewController.h */, + 62F55CD618C1180200A7E1CC /* ViewController.m */, + 62F55CD818C1180200A7E1CC /* Images.xcassets */, + 62F55CC718C1180200A7E1CC /* Supporting Files */, + ); + path = "CCHLinkTextView Example"; + sourceTree = ""; + }; + 62F55CC718C1180200A7E1CC /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 62F55CC818C1180200A7E1CC /* CCHLinkTextView Example-Info.plist */, + 62F55CC918C1180200A7E1CC /* InfoPlist.strings */, + 62F55CCC18C1180200A7E1CC /* main.m */, + 62F55CCE18C1180200A7E1CC /* CCHLinkTextView Example-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 62F55CE518C1180200A7E1CC /* CCHLinkTextView ExampleTests */ = { + isa = PBXGroup; + children = ( + 62F55CEB18C1180200A7E1CC /* CCHLinkTextView_ExampleTests.m */, + 62F55CE618C1180200A7E1CC /* Supporting Files */, + ); + path = "CCHLinkTextView ExampleTests"; + sourceTree = ""; + }; + 62F55CE618C1180200A7E1CC /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 62F55CE718C1180200A7E1CC /* CCHLinkTextView ExampleTests-Info.plist */, + 62F55CE818C1180200A7E1CC /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 62F55CBC18C1180200A7E1CC /* CCHLinkTextView Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 62F55CEF18C1180200A7E1CC /* Build configuration list for PBXNativeTarget "CCHLinkTextView Example" */; + buildPhases = ( + 62F55CB918C1180200A7E1CC /* Sources */, + 62F55CBA18C1180200A7E1CC /* Frameworks */, + 62F55CBB18C1180200A7E1CC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "CCHLinkTextView Example"; + productName = "CCHLinkTextView Example"; + productReference = 62F55CBD18C1180200A7E1CC /* CCHLinkTextView Example.app */; + productType = "com.apple.product-type.application"; + }; + 62F55CDD18C1180200A7E1CC /* CCHLinkTextView ExampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 62F55CF218C1180200A7E1CC /* Build configuration list for PBXNativeTarget "CCHLinkTextView ExampleTests" */; + buildPhases = ( + 62F55CDA18C1180200A7E1CC /* Sources */, + 62F55CDB18C1180200A7E1CC /* Frameworks */, + 62F55CDC18C1180200A7E1CC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 62F55CE418C1180200A7E1CC /* PBXTargetDependency */, + ); + name = "CCHLinkTextView ExampleTests"; + productName = "CCHLinkTextView ExampleTests"; + productReference = 62F55CDE18C1180200A7E1CC /* CCHLinkTextView ExampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 62F55CB518C1180200A7E1CC /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0500; + ORGANIZATIONNAME = "Claus Höfele"; + TargetAttributes = { + 62F55CDD18C1180200A7E1CC = { + TestTargetID = 62F55CBC18C1180200A7E1CC; + }; + }; + }; + buildConfigurationList = 62F55CB818C1180200A7E1CC /* Build configuration list for PBXProject "CCHLinkTextView Example" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 62F55CB418C1180200A7E1CC; + productRefGroup = 62F55CBE18C1180200A7E1CC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 62F55CBC18C1180200A7E1CC /* CCHLinkTextView Example */, + 62F55CDD18C1180200A7E1CC /* CCHLinkTextView ExampleTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 62F55CBB18C1180200A7E1CC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 62F55CD918C1180200A7E1CC /* Images.xcassets in Resources */, + 62F55CCB18C1180200A7E1CC /* InfoPlist.strings in Resources */, + 62F55CD418C1180200A7E1CC /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 62F55CDC18C1180200A7E1CC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 62F55CEA18C1180200A7E1CC /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 62F55CB918C1180200A7E1CC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 623AC49518C11BAD000962A0 /* CCHLinkTextView.m in Sources */, + 62F55CD718C1180200A7E1CC /* ViewController.m in Sources */, + 62F55CD118C1180200A7E1CC /* AppDelegate.m in Sources */, + 62F55CCD18C1180200A7E1CC /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 62F55CDA18C1180200A7E1CC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 62F55CEC18C1180200A7E1CC /* CCHLinkTextView_ExampleTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 62F55CE418C1180200A7E1CC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 62F55CBC18C1180200A7E1CC /* CCHLinkTextView Example */; + targetProxy = 62F55CE318C1180200A7E1CC /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 62F55CC918C1180200A7E1CC /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 62F55CCA18C1180200A7E1CC /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 62F55CD218C1180200A7E1CC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 62F55CD318C1180200A7E1CC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 62F55CE818C1180200A7E1CC /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 62F55CE918C1180200A7E1CC /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 62F55CED18C1180200A7E1CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 62F55CEE18C1180200A7E1CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 62F55CF018C1180200A7E1CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch"; + INFOPLIST_FILE = "CCHLinkTextView Example/CCHLinkTextView Example-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 62F55CF118C1180200A7E1CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch"; + INFOPLIST_FILE = "CCHLinkTextView Example/CCHLinkTextView Example-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 62F55CF318C1180200A7E1CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CCHLinkTextView Example.app/CCHLinkTextView Example"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "CCHLinkTextView ExampleTests/CCHLinkTextView ExampleTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Debug; + }; + 62F55CF418C1180200A7E1CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CCHLinkTextView Example.app/CCHLinkTextView Example"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch"; + INFOPLIST_FILE = "CCHLinkTextView ExampleTests/CCHLinkTextView ExampleTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 62F55CB818C1180200A7E1CC /* Build configuration list for PBXProject "CCHLinkTextView Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 62F55CED18C1180200A7E1CC /* Debug */, + 62F55CEE18C1180200A7E1CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 62F55CEF18C1180200A7E1CC /* Build configuration list for PBXNativeTarget "CCHLinkTextView Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 62F55CF018C1180200A7E1CC /* Debug */, + 62F55CF118C1180200A7E1CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 62F55CF218C1180200A7E1CC /* Build configuration list for PBXNativeTarget "CCHLinkTextView ExampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 62F55CF318C1180200A7E1CC /* Debug */, + 62F55CF418C1180200A7E1CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 62F55CB518C1180200A7E1CC /* Project object */; +} diff --git a/CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..667781d --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.h b/CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.h new file mode 100644 index 0000000..295136c --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.m b/CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.m new file mode 100644 index 0000000..dfb8c6d --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/AppDelegate.m @@ -0,0 +1,46 @@ +// +// AppDelegate.m +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/Base.lproj/Main.storyboard b/CCHLinkTextView Example/CCHLinkTextView Example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..0a4c5ba --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/Base.lproj/Main.storyboard @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Info.plist b/CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Info.plist new file mode 100644 index 0000000..3139cff --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.claushoefele.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch b/CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch new file mode 100644 index 0000000..82a2bb4 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/CCHLinkTextView Example-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/AppIcon.appiconset/Contents.json b/CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a396706 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/LaunchImage.launchimage/Contents.json b/CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..c79ebd3 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/ViewController.h b/CCHLinkTextView Example/CCHLinkTextView Example/ViewController.h new file mode 100644 index 0000000..1588a16 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/ViewController.h @@ -0,0 +1,13 @@ +// +// ViewController.h +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import + +@interface ViewController : UITableViewController + +@end diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/ViewController.m b/CCHLinkTextView Example/CCHLinkTextView Example/ViewController.m new file mode 100644 index 0000000..14e9439 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/ViewController.m @@ -0,0 +1,38 @@ +// +// ViewController.m +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import "ViewController.h" + +#import "CCHLinkTextView.h" +#import "CCHLinkTextViewDelegate.h" + +@interface ViewController () + +@property (weak, nonatomic) IBOutlet CCHLinkTextView *storyboardTextView; + +@end + +@implementation ViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.storyboardTextView.editable = NO; + + [self.storyboardTextView addLinkForRange:NSMakeRange(0, 10)]; + [self.storyboardTextView addLinkForRange:NSMakeRange(100, 5)]; + self.storyboardTextView.linkDelegate = self; +} + +- (void)linkTextView:(CCHLinkTextView *)linkTextView didTapLinkAtCharacterIndex:(NSUInteger)characterIndex +{ + NSLog(@"Link tapped"); +} + +@end diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/en.lproj/InfoPlist.strings b/CCHLinkTextView Example/CCHLinkTextView Example/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/CCHLinkTextView Example/CCHLinkTextView Example/main.m b/CCHLinkTextView Example/CCHLinkTextView Example/main.m new file mode 100644 index 0000000..3d2227f --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView Example/main.m @@ -0,0 +1,18 @@ +// +// main.m +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView ExampleTests-Info.plist b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView ExampleTests-Info.plist new file mode 100644 index 0000000..e1590c2 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView ExampleTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.claushoefele.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView_ExampleTests.m b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView_ExampleTests.m new file mode 100644 index 0000000..9e1ec91 --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextView_ExampleTests.m @@ -0,0 +1,34 @@ +// +// CCHLinkTextView_ExampleTests.m +// CCHLinkTextView ExampleTests +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import + +@interface CCHLinkTextView_ExampleTests : XCTestCase + +@end + +@implementation CCHLinkTextView_ExampleTests + +- (void)setUp +{ + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown +{ + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample +{ + XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); +} + +@end diff --git a/CCHLinkTextView Example/CCHLinkTextView ExampleTests/en.lproj/InfoPlist.strings b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/CCHLinkTextView/CCHLinkTextView.h b/CCHLinkTextView/CCHLinkTextView.h new file mode 100644 index 0000000..4072d06 --- /dev/null +++ b/CCHLinkTextView/CCHLinkTextView.h @@ -0,0 +1,19 @@ +// +// CCHLinkTextView.h +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import + +@protocol CCHLinkTextViewDelegate; + +@interface CCHLinkTextView : UITextView + +@property (nonatomic, weak) id linkDelegate; + +- (void)addLinkForRange:(NSRange)range; + +@end diff --git a/CCHLinkTextView/CCHLinkTextView.m b/CCHLinkTextView/CCHLinkTextView.m new file mode 100644 index 0000000..42b7871 --- /dev/null +++ b/CCHLinkTextView/CCHLinkTextView.m @@ -0,0 +1,88 @@ +// +// CCHLinkTextView.m +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +// Based on http://stackoverflow.com/questions/19332283/detecting-taps-on-attributed-text-in-a-uitextview-on-ios-7 + +#import "CCHLinkTextView.h" + +#import "CCHLinkTextViewDelegate.h" + +@interface CCHLinkTextView () + +@property (nonatomic, strong) NSMutableArray *linkRanges; + +@end + +@implementation CCHLinkTextView + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self setUp]; + } + return self; +} + +- (void)awakeFromNib +{ + [self setUp]; +} + +- (void)setUp +{ + self.linkRanges = [NSMutableArray array]; + + // http://stackoverflow.com/questions/15628133/uitapgesturerecognizer-make-it-work-on-touch-down-not-touch-up + UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(textTapped:)]; + [self addGestureRecognizer:tapGestureRecognizer]; +} + +- (void)textTapped:(UITapGestureRecognizer *)recognizer +{ + if (recognizer.state == UIGestureRecognizerStateEnded) { + CGPoint location = [recognizer locationInView:self]; + location.x -= self.textContainerInset.left; + location.y -= self.textContainerInset.top; + + NSUInteger characterIndex = [self.layoutManager characterIndexForPoint:location inTextContainer:self.textContainer fractionOfDistanceBetweenInsertionPoints:NULL]; + for (NSValue *value in self.linkRanges) { + NSRange range = value.rangeValue; + if (NSLocationInRange(characterIndex, range)) { + [self linkTappedAtCharacterIndex:characterIndex range:range]; + } + } + } +} + +- (void)linkTappedAtCharacterIndex:(NSUInteger)characterIndex range:(NSRange)range +{ +// NSDictionary *attributes = @{NSBackgroundColorAttributeName : UIColor.redColor}; +// [self updateWithAttributes:attributes range:range]; + + if ([self.linkDelegate respondsToSelector:@selector(linkTextView:didTapLinkAtCharacterIndex:)]) { + [self.linkDelegate linkTextView:self didTapLinkAtCharacterIndex:characterIndex]; + } +} + +- (void)addLinkForRange:(NSRange)range +{ + [self.linkRanges addObject:[NSValue valueWithRange:range]]; + + NSDictionary *attributes = @{NSBackgroundColorAttributeName : UIColor.greenColor}; + [self updateWithAttributes:attributes range:range]; +} + +- (void)updateWithAttributes:(NSDictionary *)attributes range:(NSRange)range +{ + NSMutableAttributedString *attributedText = [self.attributedText mutableCopy]; + [attributedText addAttributes:attributes range:range]; + self.attributedText = attributedText; +} + +@end diff --git a/CCHLinkTextView/CCHLinkTextViewDelegate.h b/CCHLinkTextView/CCHLinkTextViewDelegate.h new file mode 100644 index 0000000..8fabcdb --- /dev/null +++ b/CCHLinkTextView/CCHLinkTextViewDelegate.h @@ -0,0 +1,16 @@ +// +// CCHLinkTextViewDelegate.h +// CCHLinkTextView Example +// +// Created by Claus Höfele on 28.02.14. +// Copyright (c) 2014 Claus Höfele. All rights reserved. +// + +#import + +@protocol CCHLinkTextViewDelegate + +@optional +- (void)linkTextView:(CCHLinkTextView *)linkTextView didTapLinkAtCharacterIndex:(NSUInteger)characterIndex; + +@end