diff --git a/AutoLayoutTextViews.podspec b/AutoLayoutTextViews.podspec index c339df4..e6e6222 100644 --- a/AutoLayoutTextViews.podspec +++ b/AutoLayoutTextViews.podspec @@ -1,8 +1,8 @@ Pod::Spec.new do |s| s.platform = :ios - s.ios.deployment_target = "7.0" + s.ios.deployment_target = "9.0" s.name = "AutoLayoutTextViews" - s.version = "1.1.1" + s.version = "1.3.0" s.summary = "AutoLayoutTextViews subclasses UITextView and adds placeholder text, auto resizing, and keyboard avoiding functionality." s.homepage = "https://github.com/JRG-Developer/AutoLayoutTextViews" s.license = { :type => "MIT", :file => "LICENSE" } @@ -11,4 +11,4 @@ Pod::Spec.new do |s| s.framework = "UIKit" s.requires_arc = true s.source_files = "AutoLayoutTextViews/*.{h,m}" -end \ No newline at end of file +end diff --git a/AutoLayoutTextViews.xcodeproj/project.pbxproj b/AutoLayoutTextViews.xcodeproj/project.pbxproj index 4bcc455..44b427e 100644 --- a/AutoLayoutTextViews.xcodeproj/project.pbxproj +++ b/AutoLayoutTextViews.xcodeproj/project.pbxproj @@ -7,19 +7,19 @@ objects = { /* Begin PBXBuildFile section */ - 0154CB6408E142EDBF9F6F69 /* libPods-AutoLayoutTextViewsTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 487F164A8F7D4EEEA6DBA088 /* libPods-AutoLayoutTextViewsTests.a */; }; 42613CEF1A09AFCB00CAEDBB /* Test_ALKeyboardAvoidingTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42613CEE1A09AFCB00CAEDBB /* Test_ALKeyboardAvoidingTextView.m */; }; 446084F9194282310093A6FA /* ALAutoResizingTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 446084F8194282310093A6FA /* ALAutoResizingTextView.m */; }; 44608500194283600093A6FA /* ALPlaceholderTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 446084FF194283600093A6FA /* ALPlaceholderTextView.m */; }; 4460854D19429A520093A6FA /* ALPlaceholderTextViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4460854C19429A520093A6FA /* ALPlaceholderTextViewTests.m */; }; 4460855219429FEA0093A6FA /* Test_ALPlaceholderTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4460855119429FEA0093A6FA /* Test_ALPlaceholderTextView.m */; }; - 447BD45C19413B840062487D /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 447BD45B19413B840062487D /* XCTest.framework */; }; 447BD46819413B840062487D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 447BD46619413B840062487D /* InfoPlist.strings */; }; 449026B4197325DA00A737C3 /* ALKeyboardAvoidingTextViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448D9DFA1946801D00453E69 /* ALKeyboardAvoidingTextViewTests.m */; }; 449026B519732E9700A737C3 /* ALAutoResizingTextViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448FA0C4194639EF00F79989 /* ALAutoResizingTextViewTests.m */; }; 44A095891970F153000ED5B6 /* libAutoLayoutTextViews.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 447BD44A19413B840062487D /* libAutoLayoutTextViews.a */; }; 44FC5CEF19463C43004812F4 /* Test_ALAutoResizingTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 44FC5CEE19463C43004812F4 /* Test_ALAutoResizingTextView.m */; }; 44FC5CF21946581C004812F4 /* ALKeyboardAvoidingTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 44FC5CF11946581C004812F4 /* ALKeyboardAvoidingTextView.m */; }; + A60DACFB16749A897814CF34 /* Pods_AutoLayoutTextViewsTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EC01258D205DAEED35D82B6 /* Pods_AutoLayoutTextViewsTests.framework */; }; + C2E642A4F1441E417D339249 /* Pods_AutoLayoutTextViews.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5566B83FB9EFB1D2501F725 /* Pods_AutoLayoutTextViews.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -45,7 +45,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 015C12BBC346E6EC48E4175F /* Pods-AutoLayoutTextViewsTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests.release.xcconfig"; sourceTree = ""; }; + 3C97E920332596DBD4729856 /* Pods-AutoLayoutTextViews.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViews.release.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViews/Pods-AutoLayoutTextViews.release.xcconfig"; sourceTree = ""; }; 42613CED1A09AFCB00CAEDBB /* Test_ALKeyboardAvoidingTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test_ALKeyboardAvoidingTextView.h; sourceTree = ""; }; 42613CEE1A09AFCB00CAEDBB /* Test_ALKeyboardAvoidingTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Test_ALKeyboardAvoidingTextView.m; sourceTree = ""; }; 446084F7194282310093A6FA /* ALAutoResizingTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALAutoResizingTextView.h; sourceTree = ""; }; @@ -70,9 +70,14 @@ 44FC5CEE19463C43004812F4 /* Test_ALAutoResizingTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Test_ALAutoResizingTextView.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 44FC5CF01946581C004812F4 /* ALKeyboardAvoidingTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALKeyboardAvoidingTextView.h; sourceTree = ""; }; 44FC5CF11946581C004812F4 /* ALKeyboardAvoidingTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALKeyboardAvoidingTextView.m; sourceTree = ""; }; - 487F164A8F7D4EEEA6DBA088 /* libPods-AutoLayoutTextViewsTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AutoLayoutTextViewsTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 5A67EE64DD2D40EBBB06338F /* libPods-AOTextViewsTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AOTextViewsTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - C00AAB0725FD6ABBB55E5C19 /* Pods-AutoLayoutTextViewsTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests.debug.xcconfig"; sourceTree = ""; }; + 64858685EF628981D5ECE76A /* libPods-AutoLayoutTextViews-AutoLayoutTextViewsTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AutoLayoutTextViews-AutoLayoutTextViewsTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 8EC01258D205DAEED35D82B6 /* Pods_AutoLayoutTextViewsTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AutoLayoutTextViewsTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9E5D89973620E899D9995AA5 /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.debug.xcconfig"; sourceTree = ""; }; + B90A51AFD8D34D01331B1B4C /* Pods-AutoLayoutTextViewsTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests.debug.xcconfig"; sourceTree = ""; }; + D1D2A9FC6FA1EE2FCB9D6CA4 /* Pods-AutoLayoutTextViewsTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests.release.xcconfig"; sourceTree = ""; }; + D5566B83FB9EFB1D2501F725 /* Pods_AutoLayoutTextViews.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AutoLayoutTextViews.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F709BA331C6B0ADAE8E98165 /* Pods-AutoLayoutTextViews.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViews.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViews/Pods-AutoLayoutTextViews.debug.xcconfig"; sourceTree = ""; }; + FA9A3324D32230CC88F7A991 /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -80,6 +85,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C2E642A4F1441E417D339249 /* Pods_AutoLayoutTextViews.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -88,8 +94,7 @@ buildActionMask = 2147483647; files = ( 44A095891970F153000ED5B6 /* libAutoLayoutTextViews.a in Frameworks */, - 447BD45C19413B840062487D /* XCTest.framework in Frameworks */, - 0154CB6408E142EDBF9F6F69 /* libPods-AutoLayoutTextViewsTests.a in Frameworks */, + A60DACFB16749A897814CF34 /* Pods_AutoLayoutTextViewsTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -139,7 +144,7 @@ 447BD46319413B840062487D /* AutoLayoutTextViewsTests */, 447BD44C19413B840062487D /* Frameworks */, 447BD44B19413B840062487D /* Products */, - 4DE5F4F0AF09DE466948CCA8 /* Pods */, + 7F3FDEA9E08B7C5B59C4421E /* Pods */, ); sourceTree = ""; }; @@ -158,8 +163,9 @@ 447BD44D19413B840062487D /* Foundation.framework */, 447BD45B19413B840062487D /* XCTest.framework */, 447BD45E19413B840062487D /* UIKit.framework */, - 5A67EE64DD2D40EBBB06338F /* libPods-AOTextViewsTests.a */, - 487F164A8F7D4EEEA6DBA088 /* libPods-AutoLayoutTextViewsTests.a */, + 64858685EF628981D5ECE76A /* libPods-AutoLayoutTextViews-AutoLayoutTextViewsTests.a */, + D5566B83FB9EFB1D2501F725 /* Pods_AutoLayoutTextViews.framework */, + 8EC01258D205DAEED35D82B6 /* Pods_AutoLayoutTextViewsTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -201,11 +207,15 @@ name = "Supporting Files"; sourceTree = ""; }; - 4DE5F4F0AF09DE466948CCA8 /* Pods */ = { + 7F3FDEA9E08B7C5B59C4421E /* Pods */ = { isa = PBXGroup; children = ( - C00AAB0725FD6ABBB55E5C19 /* Pods-AutoLayoutTextViewsTests.debug.xcconfig */, - 015C12BBC346E6EC48E4175F /* Pods-AutoLayoutTextViewsTests.release.xcconfig */, + F709BA331C6B0ADAE8E98165 /* Pods-AutoLayoutTextViews.debug.xcconfig */, + 3C97E920332596DBD4729856 /* Pods-AutoLayoutTextViews.release.xcconfig */, + B90A51AFD8D34D01331B1B4C /* Pods-AutoLayoutTextViewsTests.debug.xcconfig */, + D1D2A9FC6FA1EE2FCB9D6CA4 /* Pods-AutoLayoutTextViewsTests.release.xcconfig */, + 9E5D89973620E899D9995AA5 /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.debug.xcconfig */, + FA9A3324D32230CC88F7A991 /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsTests.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -217,9 +227,11 @@ isa = PBXNativeTarget; buildConfigurationList = 447BD46D19413B840062487D /* Build configuration list for PBXNativeTarget "AutoLayoutTextViews" */; buildPhases = ( + 0A8DE686AB7C5D1C10615584 /* [CP] Check Pods Manifest.lock */, 447BD44619413B840062487D /* Sources */, 447BD44719413B840062487D /* Frameworks */, 447BD44819413B840062487D /* CopyFiles */, + DF5E9AB8F4F64E84FD40E6FA /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -234,11 +246,12 @@ isa = PBXNativeTarget; buildConfigurationList = 447BD47019413B840062487D /* Build configuration list for PBXNativeTarget "AutoLayoutTextViewsTests" */; buildPhases = ( - 7187785AB32A4D1A8D893AA5 /* Check Pods Manifest.lock */, + 05BA7F88660374D9CE33FF7C /* [CP] Check Pods Manifest.lock */, 447BD45619413B840062487D /* Sources */, 447BD45719413B840062487D /* Frameworks */, 447BD45819413B840062487D /* Resources */, - 3D0B36F7E6184547AF32BA2F /* Copy Pods Resources */, + C7270F5A23C5C508F495F0C7 /* [CP] Embed Pods Frameworks */, + 48F7E2847664EC8FFB336E64 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -257,7 +270,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = AL; - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = ""; }; buildConfigurationList = 447BD44519413B840062487D /* Build configuration list for PBXProject "AutoLayoutTextViews" */; @@ -290,14 +303,50 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 3D0B36F7E6184547AF32BA2F /* Copy Pods Resources */ = { + 05BA7F88660374D9CE33FF7C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "Copy Pods Resources"; + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-AutoLayoutTextViewsTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 0A8DE686AB7C5D1C10615584 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-AutoLayoutTextViews-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 48F7E2847664EC8FFB336E64 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -305,19 +354,39 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 7187785AB32A4D1A8D893AA5 /* Check Pods Manifest.lock */ = { + C7270F5A23C5C508F495F0C7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Expecta/Expecta.framework", + "${BUILT_PRODUCTS_DIR}/OCMock/OCMock.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AutoLayoutTextViewsTests/Pods-AutoLayoutTextViewsTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + DF5E9AB8F4F64E84FD40E6FA /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AutoLayoutTextViews/Pods-AutoLayoutTextViews-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -381,12 +450,18 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -399,7 +474,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.1; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -418,19 +493,24 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; 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_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.1; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; @@ -438,6 +518,7 @@ }; 447BD46E19413B840062487D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = F709BA331C6B0ADAE8E98165 /* Pods-AutoLayoutTextViews.debug.xcconfig */; buildSettings = { DSTROOT = /tmp/AutoLayoutTextViews.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -450,6 +531,7 @@ }; 447BD46F19413B840062487D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 3C97E920332596DBD4729856 /* Pods-AutoLayoutTextViews.release.xcconfig */; buildSettings = { DSTROOT = /tmp/AutoLayoutTextViews.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -462,13 +544,8 @@ }; 447BD47119413B840062487D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C00AAB0725FD6ABBB55E5C19 /* Pods-AutoLayoutTextViewsTests.debug.xcconfig */; + baseConfigurationReference = B90A51AFD8D34D01331B1B4C /* Pods-AutoLayoutTextViewsTests.debug.xcconfig */; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - "$(DEVELOPER_FRAMEWORKS_DIR)", - ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AutoLayoutTextViews/AutoLayoutTextViews-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -476,6 +553,7 @@ "$(inherited)", ); INFOPLIST_FILE = "AutoLayoutTextViewsTests/AutoLayoutTextViewsTests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.jrgdeveloper.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = AutoLayoutTextViewsTests; WRAPPER_EXTENSION = xctest; }; @@ -483,16 +561,12 @@ }; 447BD47219413B840062487D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 015C12BBC346E6EC48E4175F /* Pods-AutoLayoutTextViewsTests.release.xcconfig */; + baseConfigurationReference = D1D2A9FC6FA1EE2FCB9D6CA4 /* Pods-AutoLayoutTextViewsTests.release.xcconfig */; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - "$(DEVELOPER_FRAMEWORKS_DIR)", - ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AutoLayoutTextViews/AutoLayoutTextViews-Prefix.pch"; INFOPLIST_FILE = "AutoLayoutTextViewsTests/AutoLayoutTextViewsTests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.jrgdeveloper.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = AutoLayoutTextViewsTests; WRAPPER_EXTENSION = xctest; }; diff --git a/AutoLayoutTextViews.xcworkspace/contents.xcworkspacedata b/AutoLayoutTextViews.xcworkspace/contents.xcworkspacedata index e1d0d7e..41cf46a 100644 --- a/AutoLayoutTextViews.xcworkspace/contents.xcworkspacedata +++ b/AutoLayoutTextViews.xcworkspace/contents.xcworkspacedata @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + diff --git a/AutoLayoutTextViews/ALAutoResizingTextView.h b/AutoLayoutTextViews/ALAutoResizingTextView.h index 8d58139..69d1c3d 100644 --- a/AutoLayoutTextViews/ALAutoResizingTextView.h +++ b/AutoLayoutTextViews/ALAutoResizingTextView.h @@ -24,6 +24,8 @@ #import "ALPlaceholderTextView.h" +NS_ASSUME_NONNULL_BEGIN + @class ALAutoResizingTextView; /** @@ -36,8 +38,8 @@ * Tells the delegate that the text view's height is about to change. * * @param textView The text view whose height is about to change - * @param oldHeight The current height of the text view's frame - * @param newHeight The new height of the text view's frame + * @param oldHeight The current height of the text view + * @param newHeight The new height of the text view * * @discussion This method gets called in the animation block. */ @@ -47,12 +49,13 @@ * Tells the delegate that the text view's height did change. * * @param textView The text view whose height did change - * @param oldHeight The previous height of the text view's frame - * @param newHeight The new height of the text view's frame + * @param oldHeight The previous height of the text view + * @param newHeight The current height of the text view * * @discussion This method gets called in the animation completion block. */ - (void)textView:(ALAutoResizingTextView *)textView didChangeFromHeight:(CGFloat)oldHeight toHeight:(CGFloat)newHeight; + @end /** @@ -63,7 +66,7 @@ /** * The object that acts as the delegate of the text view. The delegate should conform to `ALAutoResizingTextViewDelegate`, which conforms to `ALTextViewDelegate` and `UITextViewDelegate`. */ -@property (weak, nonatomic) id delegate; +@property (weak, nonatomic, nullable) id delegate; /** * The minimum height for the text view. @@ -71,7 +74,7 @@ * @discussion The default value is `0`. * If you attempt to set a negative value, `minimumHeight` will be set to `0`. */ -@property (assign, nonatomic) CGFloat minimumHeight; +@property (assign, nonatomic) IBInspectable CGFloat minimumHeight; /** * The maximum height for the text view. @@ -79,7 +82,7 @@ * @discussion The default value is `CGFloat_MAX`. * If you attempt to set a value less than or equal to zero, `maximumHeight` will be set to `CGFloat_Max`. */ -@property (assign, nonatomic) CGFloat maximumHeight; +@property (assign, nonatomic) IBInspectable CGFloat maximumHeight; /** * The autoresizing animation duration. @@ -87,7 +90,8 @@ * @discussion The default value is `0.2`. * If you set this value to `0`, the height will be updated without animation. */ -@property (nonatomic) NSTimeInterval autoresizingAnimationDuration; +@property (assign, nonatomic) IBInspectable NSTimeInterval autoresizingAnimationDuration +__deprecated_msg("this is now entirely ignored"); /** * The height constraint @@ -95,7 +99,7 @@ * @discussion If this outlet isn't connected, it will try to be determined by iterating through its `self.constraints`. * @warning If you do not explicitly set this outlet, and it's *not* able to be determined, this class will throw a runtime exception. */ -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightConstraint; +@property (weak, nonatomic, null_unspecified) IBOutlet NSLayoutConstraint *heightConstraint; /** * The height the text view is changing *to* @@ -108,3 +112,5 @@ @property (assign, nonatomic) CGFloat oldHeight; @end + +NS_ASSUME_NONNULL_END diff --git a/AutoLayoutTextViews/ALAutoResizingTextView.m b/AutoLayoutTextViews/ALAutoResizingTextView.m index 27fe5ce..1cb29ef 100644 --- a/AutoLayoutTextViews/ALAutoResizingTextView.m +++ b/AutoLayoutTextViews/ALAutoResizingTextView.m @@ -25,16 +25,15 @@ #import "ALAutoResizingTextView.h" @implementation ALAutoResizingTextView +@dynamic delegate; #pragma mark - Object Lifecycle - (void)commonInit { [super commonInit]; - _minimumHeight = 0.0f; _maximumHeight = CGFLOAT_MAX; - _autoresizingAnimationDuration = 0.2f; } #pragma mark - View Setup @@ -53,6 +52,9 @@ - (void)findHeightConstraint for (NSLayoutConstraint *constraint in self.constraints) { if ([self isHeightConstraint:constraint]) { self.heightConstraint = constraint; + if (self.minimumHeight == 0) { + self.minimumHeight = constraint.constant; + } break; } } @@ -65,28 +67,37 @@ - (BOOL)isHeightConstraint:(NSLayoutConstraint *)constraint #pragma mark - Custom Accessors +- (void)setBounds:(CGRect)newBounds +{ + [super setBounds:newBounds]; + [self updateHeightConstraint]; +} + +- (void)setFrame:(CGRect)frame +{ + [super setFrame:frame]; + [self updateHeightConstraint]; +} + - (void)setMaximumHeight:(CGFloat)maximumHeight { _maximumHeight = maximumHeight > 0 ? maximumHeight : CGFLOAT_MAX; - [self setNeedsDisplay]; + [self updateHeightConstraint]; } --(void)setMinimumHeight:(CGFloat)minimumHeight +- (void)setMinimumHeight:(CGFloat)minimumHeight { - _minimumHeight = minimumHeight > 0 ? minimumHeight : 0; - [self setNeedsDisplay]; + _minimumHeight = fmaxf(0, minimumHeight); + [self updateHeightConstraint]; } #pragma mark - View - (void)layoutSubviews { - NSAssert(self.heightConstraint, @"ALAutoResizingTextView is missing a height constraint. ALAutoResizingTextView " - @"relies on auto layout and will not work if its `heightConstraint` is not set."); - + [self invalidateIntrinsicContentSize]; + [self setNeedsDisplay]; [super layoutSubviews]; - [self setNeedsUpdateConstraints]; - [self updateConstraintsIfNeeded]; } - (void)updateConstraints @@ -97,78 +108,51 @@ - (void)updateConstraints - (void)updateHeightConstraint { - self.oldHeight = self.heightConstraint.constant; - self.newHeight = [self calculateNewHeight]; + CGFloat oldHeight = self.heightConstraint.constant; + CGFloat newHeight = [self calculateNewHeight]; - if (![self didHeightChange]) { - return; - } + if (oldHeight == newHeight) { return; } - if ([self shouldAnimateHeightChange]) { - [self animateHeightChange]; + self.oldHeight = oldHeight; + self.newHeight = newHeight; + + if (self.newHeight >= self.maximumHeight) { + [self setScrollEnabled:YES]; } else { - [self setNewHeightWithoutAnimation]; + [self setScrollEnabled:NO]; } + + [self performHeightWillUpdate]; + [self performHeightDidUpdate]; } - (CGFloat)calculateNewHeight { - CGFloat height = [self heightThatFitsContents]; - height = fminf(height, self.maximumHeight); - height = fmaxf(height, self.minimumHeight); - return ceilf(height); -} - -- (CGFloat)heightThatFitsContents -{ - CGSize size = [self sizeThatFits:self.frame.size]; - return size.height + self.contentInset.top; -} - -- (BOOL)didHeightChange -{ - return self.newHeight != self.oldHeight; -} - -- (BOOL)shouldAnimateHeightChange -{ - return self.autoresizingAnimationDuration > 0 && ![self shouldDrawPlaceholder]; -} - -- (void)animateHeightChange -{ - [UIView animateWithDuration:self.autoresizingAnimationDuration - delay:0.0f - options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState - animations:[self animationBlock] - completion:[self completionBlock]]; -} - -- (void)setNewHeightWithoutAnimation -{ - [self animationBlock](); - [self completionBlock](YES); + CGFloat height = [self sizeThatFits:self.frame.size].height; + + if (height > self.maximumHeight) { + height = self.maximumHeight; + + } else if (height < self.minimumHeight) { + height = self.minimumHeight; + } + return height; } -- (void (^)())animationBlock +- (void)performHeightWillUpdate { - return ^{ - if ([self.delegate respondsToSelector:@selector(textView:willChangeFromHeight:toHeight:)]) { - [self.delegate textView:self willChangeFromHeight:self.oldHeight toHeight:self.newHeight]; - } - self.heightConstraint.constant = self.newHeight; - }; + if (self.delegate && [self.delegate respondsToSelector:@selector(textView:willChangeFromHeight:toHeight:)]) { + [self.delegate textView:self willChangeFromHeight:self.oldHeight toHeight:self.newHeight]; + } + self.heightConstraint.constant = self.newHeight; } -- (void(^)(BOOL))completionBlock +- (void)performHeightDidUpdate { - return ^(BOOL finished) { - - if ([self.delegate respondsToSelector:@selector(textView:didChangeFromHeight:toHeight:)]) { - [self.delegate textView:self didChangeFromHeight:self.oldHeight toHeight:self.newHeight]; - } - }; + if (self.delegate && [self.delegate respondsToSelector:@selector(textView:didChangeFromHeight:toHeight:)]) { + [self.delegate textView:self didChangeFromHeight:self.oldHeight toHeight:self.newHeight]; + } } @end diff --git a/AutoLayoutTextViews/ALKeyboardAvoidingTextView.h b/AutoLayoutTextViews/ALKeyboardAvoidingTextView.h index 35f9aae..b3b2c9c 100644 --- a/AutoLayoutTextViews/ALKeyboardAvoidingTextView.h +++ b/AutoLayoutTextViews/ALKeyboardAvoidingTextView.h @@ -24,6 +24,8 @@ #import "ALPlaceholderTextView.h" +NS_ASSUME_NONNULL_BEGIN + /** * `ALKeyboardAvoidingTextView` adds keyboard avoiding functionality to `ALPlaceholderTextView`. */ @@ -35,6 +37,8 @@ * @discussion If this outlet isn't connected, it will try to be determined by iterating through its `superview.constraints`. * @warning If you do not explicitly set this outlet, and it's *not* able to be determined, this class will throw a runtime exception. */ -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraintToBottomLayoutGuide; +@property (weak, nonatomic, null_unspecified) IBOutlet NSLayoutConstraint *bottomConstraintToBottomLayoutGuide; @end + +NS_ASSUME_NONNULL_END diff --git a/AutoLayoutTextViews/ALKeyboardAvoidingTextView.m b/AutoLayoutTextViews/ALKeyboardAvoidingTextView.m index 0fa5a6b..d7abebe 100644 --- a/AutoLayoutTextViews/ALKeyboardAvoidingTextView.m +++ b/AutoLayoutTextViews/ALKeyboardAvoidingTextView.m @@ -24,6 +24,10 @@ #import "ALKeyboardAvoidingTextView.h" +@interface ALKeyboardAvoidingTextView() +@property (nonatomic, assign) CGFloat bottomConstraintToBottomLayoutGuideConstant; +@end + @implementation ALKeyboardAvoidingTextView #pragma mark - View Setup @@ -63,6 +67,18 @@ - (BOOL)secondItemMatchesBottomConstraint:(NSLayoutConstraint *)constraint return constraint.secondItem == self && constraint.secondAttribute == NSLayoutAttributeBottom; } +#pragma mark - Custom Accessors + +- (void)setBottomConstraintToBottomLayoutGuide:(NSLayoutConstraint *)bottomConstraintToBottomLayoutGuide { + + if (_bottomConstraintToBottomLayoutGuide == bottomConstraintToBottomLayoutGuide) { + return; + } + + _bottomConstraintToBottomLayoutGuide = bottomConstraintToBottomLayoutGuide; + _bottomConstraintToBottomLayoutGuideConstant = bottomConstraintToBottomLayoutGuide.constant; +} + #pragma mark - Notifications #pragma mark - keyboardWillShow: @@ -99,7 +115,9 @@ - (CGFloat)constraintConstantMultiplier - (void)keyboardWillHide:(NSNotification *)notification { [super keyboardWillHide:notification]; - [self setBottomConstraintConstant:0 animationInfo:[notification userInfo] animated:![self shouldDrawPlaceholder]]; + [self setBottomConstraintConstant:self.bottomConstraintToBottomLayoutGuideConstant + animationInfo:[notification userInfo] + animated:![self shouldDrawPlaceholder]]; } #pragma mark - setBottomConstant: animationInfo: animated: @@ -113,15 +131,25 @@ - (void)setBottomConstraintConstant:(CGFloat)constant animationInfo:(NSDictionar self.bottomConstraintToBottomLayoutGuide.constant = constant; if (!animated) { - [self layoutIfNeeded]; + [self updateConstraintsIfNeeded]; return; } + [self setNeedsLayout]; + [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; [UIView setAnimationCurve:[info[UIKeyboardAnimationCurveUserInfoKey] integerValue]]; [UIView setAnimationBeginsFromCurrentState:YES]; + + // Warning-- this method is needed to animate scrolling to selection, but this call isn't in the unit tests + // there's some issues around testing this that I haven't been able to get around... :/ -JRG + if (!self.selectedTextRange.empty) { + self.contentOffset = [self caretRectForPosition:self.selectedTextRange.start].origin; + } + [self layoutIfNeeded]; + [UIView commitAnimations]; } diff --git a/AutoLayoutTextViews/ALPlaceholderTextView.h b/AutoLayoutTextViews/ALPlaceholderTextView.h index 522e0d7..d6b13fc 100644 --- a/AutoLayoutTextViews/ALPlaceholderTextView.h +++ b/AutoLayoutTextViews/ALPlaceholderTextView.h @@ -24,31 +24,43 @@ #import +NS_ASSUME_NONNULL_BEGIN + /** * `ALPlaceholderTextView` adds a placeholder to `UITextView` */ @interface ALPlaceholderTextView : UITextView +/** + * This is a proxy property for setting `layer.borderColor`. + */ +@property (strong, nonatomic, nullable) IBInspectable UIColor *borderColor; + +/** + * This is a proxy property for setting `layer.borderWidth`. + */ +@property (assign, nonatomic) IBInspectable CGFloat borderWidth; + /** * The string that is displayed when there is no other text in the text field * * @discussion The default value is `nil`. */ -@property (strong, nonatomic) NSString *placeholder; +@property (strong, nonatomic, nullable) IBInspectable NSString *placeholder; /** * The color of the placeholder * * @discussion The default value is `[UIColor lightGrayColor]`. */ -@property (strong, nonatomic) UIColor *placeholderColor; +@property (strong, nonatomic, nonnull) IBInspectable UIColor *placeholderColor; /** * The placeholder insets * - * @discussion The default value is set to `UIEdgeInsetsMake(8.0f, 4.0f, 0.0f, 0.0f)`. + * @discussion The default value is set to `UIEdgeInsetsMake(8.0f, 4.0f, 8.0f, 0.0f)`. */ -@property (assign, nonatomic, readwrite) UIEdgeInsets placeholderInsets; +@property (assign, nonatomic, readwrite) IBInspectable UIEdgeInsets placeholderInsets; @end @@ -104,4 +116,12 @@ */ - (CGRect)calculatePlaceholderRectInsetInRect:(CGRect)rect; -@end \ No newline at end of file + +/** + * This method is called to request the view be redrawn. + */ +- (void)requestRedraw; + +@end + +NS_ASSUME_NONNULL_END diff --git a/AutoLayoutTextViews/ALPlaceholderTextView.m b/AutoLayoutTextViews/ALPlaceholderTextView.m index 023ae23..6d2f5c3 100644 --- a/AutoLayoutTextViews/ALPlaceholderTextView.m +++ b/AutoLayoutTextViews/ALPlaceholderTextView.m @@ -54,47 +54,41 @@ - (void)dealloc - (void)commonInit { _placeholderColor = [UIColor lightGrayColor]; - _placeholderInsets = UIEdgeInsetsMake(8.0f, 4.0f, 0.0f, 0.0f); + _placeholderInsets = UIEdgeInsetsMake(8.0f, 4.0f, 8.0f, 0.0f); self.font = self.font ?: [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; [self startObservingNotifications]; } -#pragma mark - Custom Accessors - -- (Class)viewClass -{ - return [UIView class]; -} - #pragma mark - Notifications - (void)startObservingNotifications { [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textDidChange:) - name:UITextViewTextDidChangeNotification - object:self]; + + selector:@selector(textDidChange:) + name:UITextViewTextDidChangeNotification + object:self]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textDidChange:) - name:UIApplicationDidChangeStatusBarOrientationNotification - object:nil]; + selector:@selector(textDidChange:) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillShow:) - name:UIKeyboardWillShowNotification - object:nil]; + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillHide:) - name:UIKeyboardWillHideNotification - object:nil]; + selector:@selector(keyboardWillHide:) + name:UIKeyboardWillHideNotification + object:nil]; } - (void)textDidChange:(NSNotification *)notification { - [self setNeedsDisplay]; + [self requestRedraw]; } - (void)keyboardWillShow:(NSNotification *)notification @@ -109,6 +103,13 @@ - (void)keyboardWillHide:(NSNotification *)notification #pragma mark - Custom Accessors + +- (void)setAttributedText:(NSAttributedString *)attributedText +{ + [super setAttributedText:attributedText]; + [self setNeedsDisplay]; +} + - (void)setPlaceholder:(NSString *)placeholder { if (_placeholder == placeholder) { @@ -116,7 +117,13 @@ - (void)setPlaceholder:(NSString *)placeholder } _placeholder = [placeholder copy]; - [self setNeedsDisplay]; + [self requestRedraw]; +} + +- (void)setFont:(UIFont *)font +{ + [super setFont:font]; + [self requestRedraw]; } - (void)setPlaceholderColor:(UIColor *)placeholderColor @@ -128,29 +135,85 @@ - (void)setPlaceholderColor:(UIColor *)placeholderColor _placeholderColor = placeholderColor; if ([self shouldDrawPlaceholder]) { - [self setNeedsDisplay]; + [self requestRedraw]; } } -#pragma mark - Draw Rect +- (void)setText:(NSString *)text +{ + [super setText:text]; + [self requestRedraw]; +} -- (void)drawRect:(CGRect)rect +- (void)setTextAlignment:(NSTextAlignment)textAlignment { - [super drawRect:rect]; - + [super setTextAlignment:textAlignment]; + [self requestRedraw]; +} + +- (void)requestRedraw +{ + [self invalidateIntrinsicContentSize]; + [self setNeedsDisplay]; + [self setNeedsLayout]; + [self setNeedsUpdateConstraints]; +} + +#pragma mark - Size That Fits + +- (CGSize)intrinsicContentSize { + return [self sizeThatFits:self.bounds.size]; +} + +- (CGSize)sizeThatFits:(CGSize)size +{ if (![self shouldDrawPlaceholder]) { - return; + CGSize sizeThatFits = [super sizeThatFits:size]; + sizeThatFits.width = self.bounds.size.width; + return sizeThatFits; } + + CGRect placeholderInsetRect = [self calculatePlaceholderRectInsetInRect:self.frame]; + CGRect placeholderTextRect = [self.placeholder + boundingRectWithSize:CGSizeMake(placeholderInsetRect.size.width, CGFLOAT_MAX) + options:NSStringDrawingUsesLineFragmentOrigin + attributes:[self placeholderAttributes] + context:nil]; + return CGSizeMake(self.bounds.size.width, + ceilf(placeholderTextRect.size.height) + + self.placeholderInsets.top + self.placeholderInsets.bottom); +} + +- (NSDictionary *)placeholderAttributes +{ NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; paragraphStyle.alignment = self.textAlignment; - NSDictionary *attributes = @{NSFontAttributeName: self.font, - NSParagraphStyleAttributeName: paragraphStyle, - NSForegroundColorAttributeName: self.placeholderColor}; + NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; + attributes[NSParagraphStyleAttributeName] = paragraphStyle; + + if (self.font) { + attributes[NSFontAttributeName] = self.font; + } + attributes[NSForegroundColorAttributeName] = self.placeholderColor; + + return attributes; +} + +#pragma mark - Draw Rect + +- (void)drawRect:(CGRect)rect +{ + [super drawRect:rect]; + + if (![self shouldDrawPlaceholder]) { + return; + } - [self.placeholder drawInRect:[self calculatePlaceholderRectInsetInRect:rect] withAttributes:attributes]; + [self.placeholder drawInRect:[self calculatePlaceholderRectInsetInRect:rect] + withAttributes:[self placeholderAttributes]]; } - (BOOL)shouldDrawPlaceholder @@ -160,8 +223,15 @@ - (BOOL)shouldDrawPlaceholder - (CGRect)calculatePlaceholderRectInsetInRect:(CGRect)rect { - CGRect placeholderRect = CGRectInset(rect, _placeholderInsets.left, _placeholderInsets.top); - placeholderRect.origin.y += self.contentInset.top; + CGRect placeholderRect = rect; + placeholderRect.origin.x += (self.placeholderInsets.left + self.contentInset.left); + placeholderRect.size.width -= placeholderRect.origin.x; + placeholderRect.size.width -= (self.placeholderInsets.right + self.contentInset.right); + + placeholderRect.origin.y += (self.placeholderInsets.top + self.contentInset.top); + placeholderRect.size.height -= placeholderRect.origin.y; + placeholderRect.size.height -= (self.placeholderInsets.bottom + self.contentInset.bottom); + return placeholderRect; } diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcodeproj/project.pbxproj b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcodeproj/project.pbxproj index 39733c1..0df2267 100644 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcodeproj/project.pbxproj +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcodeproj/project.pbxproj @@ -7,7 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 394B204347E2A25CF9E4FD81 /* libPods-AutoLayoutTextViewsDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CCFC0BAE800147B481EB2390 /* libPods-AutoLayoutTextViewsDemo.a */; }; + 427B15731E9D967A000DFEAD /* Launch.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 427B15721E9D967A000DFEAD /* Launch.storyboard */; }; 42D015801A09C82B00D2950F /* ALTextViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D0157F1A09C82B00D2950F /* ALTextViewCell.m */; }; + 42F31B1F1DE4A2A6002099AE /* libPods-AutoLayoutTextViewsDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42F31B1E1DE4A2A6002099AE /* libPods-AutoLayoutTextViewsDemo.a */; }; 4460851A194286690093A6FA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 44608518194286690093A6FA /* InfoPlist.strings */; }; 4460851C194286690093A6FA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4460851B194286690093A6FA /* main.m */; }; 44608520194286690093A6FA /* ALAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4460851F194286690093A6FA /* ALAppDelegate.m */; }; @@ -15,13 +18,17 @@ 44608526194286690093A6FA /* ALTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 44608525194286690093A6FA /* ALTableViewController.m */; }; 44608528194286690093A6FA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 44608527194286690093A6FA /* Images.xcassets */; }; 448D9DF61946743300453E69 /* ALTextViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 448D9DF51946743300453E69 /* ALTextViewController.m */; }; - 815B5596A10C4D67A6634888 /* libPods-AutoLayoutTextViewsDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CCFC0BAE800147B481EB2390 /* libPods-AutoLayoutTextViewsDemo.a */; }; 92D8DF881A09AB16006F106A /* ALAutoResizingTextViewTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92D8DF871A09AB16006F106A /* ALAutoResizingTextViewTableViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 2BE76039C2C7EEA18CED60A5 /* Pods-AutoLayoutTextViewsDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsDemo.release.xcconfig"; path = "../Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo.release.xcconfig"; sourceTree = ""; }; + 2DFB6B9C62D372274CCEAB0B /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.release.xcconfig"; path = "../Pods/Target Support Files/Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.release.xcconfig"; sourceTree = ""; }; + 37CC977061B34842E205F1FA /* libPods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 427B15721E9D967A000DFEAD /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = ""; }; 42D0157E1A09C82B00D2950F /* ALTextViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALTextViewCell.h; sourceTree = ""; }; 42D0157F1A09C82B00D2950F /* ALTextViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALTextViewCell.m; sourceTree = ""; }; + 42F31B1E1DE4A2A6002099AE /* libPods-AutoLayoutTextViewsDemo.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-AutoLayoutTextViewsDemo.a"; path = "/Users/Joshua/Documents/Libraries/AutoLayoutTextViews/Pods/../build/Debug-iphoneos/libPods-AutoLayoutTextViewsDemo.a"; sourceTree = ""; }; 4460850C194286690093A6FA /* AutoLayoutTextViewsDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AutoLayoutTextViewsDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44608517194286690093A6FA /* AutoLayoutTextViewsDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AutoLayoutTextViewsDemo-Info.plist"; sourceTree = ""; }; 44608519194286690093A6FA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -36,6 +43,8 @@ 448D9DF41946743300453E69 /* ALTextViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALTextViewController.h; sourceTree = ""; }; 448D9DF51946743300453E69 /* ALTextViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALTextViewController.m; sourceTree = ""; }; 51292E7F96A1AFFE4C821792 /* Pods-AutoLayoutTextViewsDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo.release.xcconfig"; sourceTree = ""; }; + 65D127BDD1EEDFD8C0FF43B7 /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.debug.xcconfig"; sourceTree = ""; }; + 818333B692AE1B0E33029DB0 /* Pods-AutoLayoutTextViewsDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsDemo.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo.debug.xcconfig"; sourceTree = ""; }; 92D8DF861A09AB16006F106A /* ALAutoResizingTextViewTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALAutoResizingTextViewTableViewController.h; sourceTree = ""; }; 92D8DF871A09AB16006F106A /* ALAutoResizingTextViewTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALAutoResizingTextViewTableViewController.m; sourceTree = ""; }; BE5DDBA6AE799EA89456BC1A /* Pods-AutoLayoutTextViewsDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutoLayoutTextViewsDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo.debug.xcconfig"; sourceTree = ""; }; @@ -47,7 +56,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 815B5596A10C4D67A6634888 /* libPods-AutoLayoutTextViewsDemo.a in Frameworks */, + 42F31B1F1DE4A2A6002099AE /* libPods-AutoLayoutTextViewsDemo.a in Frameworks */, + 394B204347E2A25CF9E4FD81 /* libPods-AutoLayoutTextViewsDemo.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -59,6 +69,10 @@ children = ( BE5DDBA6AE799EA89456BC1A /* Pods-AutoLayoutTextViewsDemo.debug.xcconfig */, 51292E7F96A1AFFE4C821792 /* Pods-AutoLayoutTextViewsDemo.release.xcconfig */, + 818333B692AE1B0E33029DB0 /* Pods-AutoLayoutTextViewsDemo.debug.xcconfig */, + 2BE76039C2C7EEA18CED60A5 /* Pods-AutoLayoutTextViewsDemo.release.xcconfig */, + 65D127BDD1EEDFD8C0FF43B7 /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.debug.xcconfig */, + 2DFB6B9C62D372274CCEAB0B /* Pods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -84,7 +98,9 @@ 4460850E194286690093A6FA /* Frameworks */ = { isa = PBXGroup; children = ( + 42F31B1E1DE4A2A6002099AE /* libPods-AutoLayoutTextViewsDemo.a */, CCFC0BAE800147B481EB2390 /* libPods-AutoLayoutTextViewsDemo.a */, + 37CC977061B34842E205F1FA /* libPods-AutoLayoutTextViews-AutoLayoutTextViewsDemo.a */, ); name = Frameworks; sourceTree = ""; @@ -132,6 +148,7 @@ 42D0157E1A09C82B00D2950F /* ALTextViewCell.h */, 42D0157F1A09C82B00D2950F /* ALTextViewCell.m */, 44608521194286690093A6FA /* Main.storyboard */, + 427B15721E9D967A000DFEAD /* Launch.storyboard */, ); name = Views; sourceTree = ""; @@ -143,11 +160,12 @@ isa = PBXNativeTarget; buildConfigurationList = 4460853E194286690093A6FA /* Build configuration list for PBXNativeTarget "AutoLayoutTextViewsDemo" */; buildPhases = ( - 48AC5D1F2B7C490899E425E0 /* Check Pods Manifest.lock */, + 48AC5D1F2B7C490899E425E0 /* [CP] Check Pods Manifest.lock */, 44608508194286690093A6FA /* Sources */, 44608509194286690093A6FA /* Frameworks */, 4460850A194286690093A6FA /* Resources */, - FB9D0AA459E34F9F8F778979 /* Copy Pods Resources */, + FB9D0AA459E34F9F8F778979 /* [CP] Copy Pods Resources */, + 39008B6E526BA84E9FB17D67 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -165,7 +183,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = AO; - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = "App-Order, LLC"; }; buildConfigurationList = 44608507194286690093A6FA /* Build configuration list for PBXProject "AutoLayoutTextViewsDemo" */; @@ -194,40 +212,59 @@ 44608528194286690093A6FA /* Images.xcassets in Resources */, 4460851A194286690093A6FA /* InfoPlist.strings in Resources */, 44608523194286690093A6FA /* Main.storyboard in Resources */, + 427B15731E9D967A000DFEAD /* Launch.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 48AC5D1F2B7C490899E425E0 /* Check Pods Manifest.lock */ = { + 39008B6E526BA84E9FB17D67 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - FB9D0AA459E34F9F8F778979 /* Copy Pods Resources */ = { + 48AC5D1F2B7C490899E425E0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "Copy Pods Resources"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-AutoLayoutTextViewsDemo-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + FB9D0AA459E34F9F8F778979 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-AutoLayoutTextViewsDemo/Pods-AutoLayoutTextViewsDemo-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -281,13 +318,19 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -300,7 +343,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.1; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -319,20 +362,25 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; 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_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.1; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; @@ -340,14 +388,14 @@ }; 4460853F194286690093A6FA /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BE5DDBA6AE799EA89456BC1A /* Pods-AutoLayoutTextViewsDemo.debug.xcconfig */; + baseConfigurationReference = 818333B692AE1B0E33029DB0 /* Pods-AutoLayoutTextViewsDemo.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Prefix.pch"; INFOPLIST_FILE = "AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.jrgdeveloper.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = AutoLayoutTextViewsDemo; WRAPPER_EXTENSION = app; }; @@ -355,14 +403,14 @@ }; 44608540194286690093A6FA /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 51292E7F96A1AFFE4C821792 /* Pods-AutoLayoutTextViewsDemo.release.xcconfig */; + baseConfigurationReference = 2BE76039C2C7EEA18CED60A5 /* Pods-AutoLayoutTextViewsDemo.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Prefix.pch"; INFOPLIST_FILE = "AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.jrgdeveloper.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = AutoLayoutTextViewsDemo; WRAPPER_EXTENSION = app; }; diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcworkspace/contents.xcworkspacedata b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 4169b5c..0000000 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.h b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.h index e1e6e42..c982f15 100644 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.h +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.h @@ -9,7 +9,7 @@ #import #import -#import +#import "AutoLayoutTextViews.h" @interface ALAutoResizingTextViewTableViewController : UITableViewController diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.m b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.m index 0581324..795d1ca 100644 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.m +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALAutoResizingTextViewTableViewController.m @@ -19,34 +19,55 @@ - (void)viewDidLoad - (void)configureTableView { - self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 44.0; + self.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableView.tableFooterView = [[UIView alloc] init]; } #pragma mark - ALAutoResizingTextViewDelegate -- (void)textView:(ALAutoResizingTextView *)textView didChangeFromHeight:(CGFloat)oldHeight toHeight:(CGFloat)newHeight -{ +- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { + + return YES; +} + +- (void)textView:(ALAutoResizingTextView *)textView didChangeFromHeight:(CGFloat)oldHeight toHeight:(CGFloat)newHeight { + + [UIView setAnimationsEnabled:NO]; + [self.tableView beginUpdates]; [self.tableView endUpdates]; + + // For some reason, on iOS 10.3.1 (or may be 10.0 and newer?), must call these TWICES... + // if only called once, the constraint changes don't get applied for some reason... seems like an Apple bug. :/ + + // This works fine on iOS 9.X versions, where or not there's 2 calls or just 1 to this method pair. + [self.tableView beginUpdates]; + [self.tableView endUpdates]; + + [UIView setAnimationsEnabled:YES]; } #pragma mark - UITableViewDataSource -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 1; -} - - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 3; + return 10; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - ALTextViewCell *cell = (ALTextViewCell *)[self.tableView dequeueReusableCellWithIdentifier:@"ALTextViewCell" forIndexPath:indexPath]; - cell.textView.placeholder = NSLocalizedString(@"Placeholder Text", nil); + ALTextViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"ALTextViewCell" forIndexPath:indexPath]; + cell.textView.tag = indexPath.row; + + if (indexPath.row == 0) { + cell.textView.placeholder = @"Please describe where the incident happened"; + + } else if (indexPath.row == 1) { + cell.textView.placeholder = @"This placeholder is just a little too long!"; + } else { + cell.textView.placeholder = nil; + } return cell; } diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALTextViewController.m b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALTextViewController.m index a08761d..572b8ee 100644 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALTextViewController.m +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/ALTextViewController.m @@ -32,7 +32,6 @@ @implementation ALTextViewController - (void)viewDidLoad { [super viewDidLoad]; - self.textView.placeholder = NSLocalizedString(@"Placeholder Text", nil); [self setUpDoneButton]; } diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Info.plist b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Info.plist index 7bcdcd7..9797c5a 100644 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Info.plist +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.jrgdeveloper.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,6 +24,8 @@ 1.0 LSRequiresIPhoneOS + UILaunchStoryboardName + Launch UIMainStoryboardFile Main UIRequiredDeviceCapabilities diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Base.lproj/Main.storyboard b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Base.lproj/Main.storyboard index 376ee77..38be3f7 100644 --- a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Base.lproj/Main.storyboard +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Base.lproj/Main.storyboard @@ -1,7 +1,12 @@ - - + + + + + - + + + @@ -9,21 +14,21 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -158,12 +166,12 @@ - + - - + + @@ -171,7 +179,7 @@ - + @@ -188,44 +196,45 @@ - + - - - + + + - + - + + + - - - + + + - + - - - - - + + + + - + @@ -237,11 +246,12 @@ + - + @@ -252,20 +262,28 @@ - + - - - + + + - + + + + + + + + + - + @@ -281,7 +299,7 @@ - + @@ -299,12 +317,12 @@ - + - + diff --git a/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Launch.storyboard b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Launch.storyboard new file mode 100644 index 0000000..9e80f05 --- /dev/null +++ b/AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo/Launch.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutoLayoutTextViewsDemo/Podfile b/AutoLayoutTextViewsDemo/Podfile deleted file mode 100644 index 113f0f2..0000000 --- a/AutoLayoutTextViewsDemo/Podfile +++ /dev/null @@ -1,5 +0,0 @@ -platform :ios, "7.0" - -target "AutoLayoutTextViewsDemo" do - pod 'AutoLayoutTextViews', :path => '../' -end diff --git a/AutoLayoutTextViewsDemo/Podfile.lock b/AutoLayoutTextViewsDemo/Podfile.lock deleted file mode 100644 index 8a34138..0000000 --- a/AutoLayoutTextViewsDemo/Podfile.lock +++ /dev/null @@ -1,14 +0,0 @@ -PODS: - - AutoLayoutTextViews (1.1.1) - -DEPENDENCIES: - - AutoLayoutTextViews (from `../`) - -EXTERNAL SOURCES: - AutoLayoutTextViews: - :path: ../ - -SPEC CHECKSUMS: - AutoLayoutTextViews: 12ca19c941122ccbf9a768739d1cfa6f5ca6ae11 - -COCOAPODS: 0.34.4 diff --git a/AutoLayoutTextViewsTests/ALAutoResizingTextViewTests.m b/AutoLayoutTextViewsTests/ALAutoResizingTextViewTests.m index 4cb191d..c2b166b 100644 --- a/AutoLayoutTextViewsTests/ALAutoResizingTextViewTests.m +++ b/AutoLayoutTextViewsTests/ALAutoResizingTextViewTests.m @@ -135,11 +135,6 @@ - (void)test___commonInit___setsMaximumHeight expect(sut.maximumHeight).to.equal(CGFLOAT_MAX); } -- (void)test___commonInit___setsAutoresizingAnimationDuration -{ - expect(sut.autoresizingAnimationDuration).to.equal(0.2f); -} - #pragma mark - awakwFromNib - Tests - (void)test___awakeFromNib___setsHeightConstraint_whenHeightConstraintFoundBy_firstItem @@ -161,112 +156,11 @@ - (void)test___awakeFromNib___setsHeightConstraint_whenHeightConstraintFoundBy_f expect(sut.heightConstraint).toNot.beNil(); } -#pragma mark - layoutSubviews - Tests - -- (void)test___layoutSubviews___calls_setNeedsUpdateConstraints -{ - // when - [sut layoutSubviews]; - - // then - expect(sut.called_setNeedsUpdateConstraints).to.beTruthy(); -} - -- (void)test___layoutSubviews___calls_updateConstraintsIfNeeded -{ - // when - [sut layoutSubviews]; - - // then - expect(sut.called_updateConstraintsIfNeeded).to.beTruthy(); -} - #pragma mark - updateConstraints - Tests -- (void)test___updateConstraints___animatesHeightChange_ifAutoresizingAnimationDurationGreaterThanZero -{ - // given - [self givenAboutToChangeHeight]; - [self givenMockViewClass]; - - OCMExpect([viewClass animateWithDuration:sut.autoresizingAnimationDuration - delay:0.0f - options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState - animations:[OCMArg any] - completion:[OCMArg any]]); - - // when - [sut updateConstraints]; - - // then - OCMVerifyAll(viewClass); -} - -- (void)test___updateConstraints___doesNotAnimateHeightChange_ifAutoresizingAnimationDurationEqualsZero -{ - [self givenAboutToChangeHeight]; - [self givenMockViewClass]; - - [[[viewClass reject] ignoringNonObjectArgs] animateWithDuration:sut.autoresizingAnimationDuration - delay:0.0f - options:UIViewAnimationOptionAllowUserInteraction | - UIViewAnimationOptionBeginFromCurrentState - animations:[OCMArg any] - completion:[OCMArg any]]; - - sut.autoresizingAnimationDuration = 0; - - // when - [sut updateConstraints]; - - // then - OCMVerifyAllWithDelay(viewClass, 0.01); -} - -- (void)test___updateConstraints___doesNotAnimateHieght_ifShouldDrawPlaceholderReturnsYES -{ - // given - sut.placeholder = @"Placeholder"; - sut.text = @""; - expect([sut shouldDrawPlaceholder]).to.beTruthy(); - - [self givenAboutToChangeHeight]; - [self givenMockViewClass]; - - [[[viewClass reject] ignoringNonObjectArgs] animateWithDuration:sut.autoresizingAnimationDuration - delay:0.0f - options:UIViewAnimationOptionAllowUserInteraction | - UIViewAnimationOptionBeginFromCurrentState - animations:[OCMArg any] - completion:[OCMArg any]]; - - // when - [sut updateConstraints]; - - // then - OCMVerifyAllWithDelay(viewClass, 0.01); -} - -- (void)test_heightChangeWithAnimation_notifies_delegate -{ - // given - [self givenMockDelegate]; - [self givenAboutToChangeHeight]; - - [[[delegate expect] ignoringNonObjectArgs] textView:sut willChangeFromHeight:0.0f toHeight:0.0f]; - [[[delegate expect] ignoringNonObjectArgs] textView:sut didChangeFromHeight:0.0f toHeight:0.0f]; - - // when - [sut updateConstraints]; - - // then - OCMVerifyAllWithDelay(delegate, 0.1); -} - -- (void)test_heightChangeWithoutAnimation_notifies_delegate +- (void)test_heightChange_notifies_delegate { // given - sut.autoresizingAnimationDuration = 0.0f; [self givenMockDelegate]; [self givenAboutToChangeHeight]; diff --git a/AutoLayoutTextViewsTests/ALKeyboardAvoidingTextViewTests.m b/AutoLayoutTextViewsTests/ALKeyboardAvoidingTextViewTests.m index f35e20f..e0299c2 100644 --- a/AutoLayoutTextViewsTests/ALKeyboardAvoidingTextViewTests.m +++ b/AutoLayoutTextViewsTests/ALKeyboardAvoidingTextViewTests.m @@ -35,6 +35,10 @@ #import +@interface ALKeyboardAvoidingTextView() +@property (nonatomic, assign) CGFloat bottomConstraintToBottomLayoutGuideConstant; +@end + @interface ALKeyboardAvoidingTextViewTests : XCTestCase @end @@ -42,6 +46,9 @@ @implementation ALKeyboardAvoidingTextViewTests { Test_ALKeyboardAvoidingTextView *sut; + CGFloat constant; + + id partialMock; id mockBottomConstraint; id mockNotification; id viewClass; @@ -57,16 +64,15 @@ - (void)setUp [super setUp]; sut = [[Test_ALKeyboardAvoidingTextView alloc] init]; - - mockBottomConstraint = OCMClassMock([NSLayoutConstraint class]); - sut.bottomConstraintToBottomLayoutGuide = mockBottomConstraint; + [self givenMockBottomConstraintWithConstant:0]; } - (void)tearDown { - [viewClass stopMocking]; - [mockNotification stopMocking]; [mockBottomConstraint stopMocking]; + [mockNotification stopMocking]; + [partialMock stopMocking]; + [viewClass stopMocking]; [super tearDown]; } @@ -95,7 +101,17 @@ - (void)givenNotificationUserInfo userInfo[UIKeyboardFrameEndUserInfoKey] = [NSValue valueWithCGRect:CGRectMake(0, 0, 320, 216)]; } -#pragma mark - Given +#pragma mark - Given - Mocks + +- (void)givenMockBottomConstraintWithConstant:(CGFloat)expected { + + [mockBottomConstraint stopMocking]; + + mockBottomConstraint = OCMClassMock([NSLayoutConstraint class]); + OCMStub([(NSLayoutConstraint *)mockBottomConstraint constant]).andReturn(expected); + + sut.bottomConstraintToBottomLayoutGuide = mockBottomConstraint; +} - (void)givenViewClass { @@ -122,6 +138,10 @@ - (void)expectDoesNotAnimateChange:(NSDictionary *)info [[viewClass reject] commitAnimations]; } +- (void)givenPartialMock { + partialMock = OCMPartialMock(sut); +} + #pragma mark - View - Tests - (void)test___awakeFromNib___sets_bottomConstraint_fromSuperViewConstraints_whenBottomConstraintIsFoundBy_firstItem @@ -164,6 +184,19 @@ - (void)test___awakeFromNib___sets_bottomConstraint_fromSuperViewConstraints_whe expect(sut.bottomConstraintToBottomLayoutGuide).toNot.beNil(); } +#pragma mark - Custom Accessors - Tests + +- (void)test___setBottomConstraintToBottomLayoutGuide___setsbottomConstraintToBottomLayoutGuideConstant { + + // given + CGFloat expected = 42; + + [self givenMockBottomConstraintWithConstant:expected]; + + // then + expect(sut.bottomConstraintToBottomLayoutGuideConstant).to.equal(expected); +} + #pragma mark - Keyboard Will Show - Tests - (void)test___keyboardWillShow___setsBottomConstraintConstant_asNegative_ifTextViewIsFirstItemInConstraint @@ -210,18 +243,20 @@ - (void)test___keyboardWillShow___callsLayoutIfNeeded_givenText expect(sut.called_layoutIfNeeded).to.beTruthy(); } -- (void)test___keyboardWillShow___callsLayoutIfNeeded_givenPlaceholderWithoutText +- (void)test___keyboardWillShow___callsUpdateConstraintsIfNeeded_givenPlaceholderWithoutText { // given [self givenMockNotification]; sut.placeholder = @"Placeholder"; + sut.text = nil; // when [sut keyboardWillShow:mockNotification]; // then - expect(sut.called_layoutIfNeeded).to.beTruthy(); + expect(sut.called_updateConstraintsIfNeeded).to.beTruthy(); + expect(sut.called_layoutIfNeeded).to.beFalsy(); } - (void)test___keyboardWillShow___animatesChange_GivenText @@ -269,14 +304,16 @@ - (void)test___keyboardWillShow___animatesChange_GivenNoPlaceholderAndNoText #pragma mark - Keyboard Will Hide Tests -- (void)test___keyboardWillHide___setsBottomConstraintConstantToZero +- (void)test___keyboardWillHide___setsBottomConstraintConstantToStoredValue { // given + CGFloat expected = 42; + sut.bottomConstraintToBottomLayoutGuideConstant = expected; + OCMStub([mockBottomConstraint secondItem]).andReturn(sut); + [self givenMockNotification]; - CGFloat expected = 0; - // when [sut keyboardWillHide:mockNotification]; @@ -298,7 +335,7 @@ - (void)test___keyboardWillHide___callsLayoutIfNeeded_givenText expect(sut.called_layoutIfNeeded).to.beTruthy(); } -- (void)test___keyboardWillHide___callsLayoutIfNeeded_givenPlaceholderWithoutText +- (void)test___keyboardWillHide___callsUpdateConstraintsIfNeeded_givenPlaceholderWithoutText { // given [self givenMockNotification]; @@ -310,7 +347,8 @@ - (void)test___keyboardWillHide___callsLayoutIfNeeded_givenPlaceholderWithoutTex [sut keyboardWillHide:mockNotification]; // then - expect(sut.called_layoutIfNeeded).to.beTruthy(); + expect(sut.called_updateConstraintsIfNeeded).to.beTruthy(); + expect(sut.called_layoutIfNeeded).to.beFalsy(); } - (void)test___keyboardWillHide___animatesChange_GivenText diff --git a/AutoLayoutTextViewsTests/ALPlaceholderTextViewTests.m b/AutoLayoutTextViewsTests/ALPlaceholderTextViewTests.m index 3f817fb..be21e3c 100644 --- a/AutoLayoutTextViewsTests/ALPlaceholderTextViewTests.m +++ b/AutoLayoutTextViewsTests/ALPlaceholderTextViewTests.m @@ -81,8 +81,10 @@ - (void)test___init___calls___commonInit - (void)test___initWithCoder___calls___commonInit { + NSCoder *coder = nil; + // when - sut = [[Test_ALPlaceholderTextView alloc] initWithCoder:nil]; + sut = [[Test_ALPlaceholderTextView alloc] initWithCoder:coder]; // then expect(sut.called_commonInit).to.beTruthy(); @@ -101,7 +103,7 @@ - (void)test_placeholderColorIsLightGrayColorByDefault - (void)test_placeholderInsetsSetToCorrectDefaultValue { // given - UIEdgeInsets expected = UIEdgeInsetsMake(8.0f, 4.0f, 0.0f, 0.0f); + UIEdgeInsets expected = UIEdgeInsetsMake(8.0f, 4.0f, 8.0f, 0.0f); // when UIEdgeInsets actual = sut.placeholderInsets; @@ -145,7 +147,8 @@ - (void)test_observes_UIKeyboardWillHideNotification - (void)test___textDidChange__calls___setNeedsDisplay { // when - [sut textDidChange:nil]; + NSNotification *notification = nil; + [sut textDidChange:notification]; // then expect(sut.called_setNeedsDisplay).to.beTruthy(); @@ -154,7 +157,8 @@ - (void)test___textDidChange__calls___setNeedsDisplay - (void)test___keyboardWillShow___calls___setNeedsDisplay { // when - [sut keyboardWillShow:nil]; + NSNotification *notification = nil; + [sut keyboardWillShow:notification]; // then expect(sut.called_setNeedsDisplay).to.beTruthy(); @@ -163,12 +167,34 @@ - (void)test___keyboardWillShow___calls___setNeedsDisplay - (void)test___keyboardWillHide___calls___setNeedsDisplay { // when - [sut keyboardWillHide:nil]; + NSNotification *notification = nil; + [sut keyboardWillHide:notification]; + + // then + expect(sut.called_setNeedsDisplay).to.beTruthy(); +} + +- (void)test___setText___calls___setsNeedsDisplay { + + // when + [sut setNeedsDisplay]; // then expect(sut.called_setNeedsDisplay).to.beTruthy(); } +- (void)test__sizeThatFits__givenLongerPlaceholderTextThanContentText_returnsSizeWithHeightFittingPlaceholder +{ + // given + sut.placeholder = @"Long Placeholder Text Long Placeholder Text Long Placeholder Text Long Placeholder Text Long Placeholder Text Long Placeholder Text"; + + // when + CGSize actual = [sut sizeThatFits:CGSizeMake(50.0f, 50.0f)]; + + // then + expect(actual.height).to.beGreaterThan(30.0f); +} + - (void)test___drawRect___returnsNO_ifHasText { // given diff --git a/AutoLayoutTextViewsTests/AutoLayoutTextViewsTests-Info.plist b/AutoLayoutTextViewsTests/AutoLayoutTextViewsTests-Info.plist index 8a2978e..169b6f7 100644 --- a/AutoLayoutTextViewsTests/AutoLayoutTextViewsTests-Info.plist +++ b/AutoLayoutTextViewsTests/AutoLayoutTextViewsTests-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.jrgdeveloper.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/AutoLayoutTextViewsTests/Test_ALAutoResizingTextView.m b/AutoLayoutTextViewsTests/Test_ALAutoResizingTextView.m index fc6a085..e40e0bb 100644 --- a/AutoLayoutTextViewsTests/Test_ALAutoResizingTextView.m +++ b/AutoLayoutTextViewsTests/Test_ALAutoResizingTextView.m @@ -44,7 +44,6 @@ - (void)setNeedsUpdateConstraints - (void)updateConstraintsIfNeeded { - [super updateConstraintsIfNeeded]; self.called_updateConstraintsIfNeeded = YES; } diff --git a/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.h b/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.h index 8a10c3a..227909f 100644 --- a/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.h +++ b/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.h @@ -26,4 +26,6 @@ @interface Test_ALKeyboardAvoidingTextView : ALKeyboardAvoidingTextView @property (assign, nonatomic) BOOL called_layoutIfNeeded; +@property (assign, nonatomic) BOOL called_updateConstraintsIfNeeded; +@property (assign, nonatomic) CGRect test_caretRect; @end diff --git a/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.m b/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.m index c88da64..4fa2418 100644 --- a/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.m +++ b/AutoLayoutTextViewsTests/Test_ALKeyboardAvoidingTextView.m @@ -26,10 +26,20 @@ @implementation Test_ALKeyboardAvoidingTextView +- (void)updateConstraintsIfNeeded +{ + [super updateConstraintsIfNeeded]; + self.called_updateConstraintsIfNeeded = YES; +} + - (void)layoutIfNeeded { [super layoutIfNeeded]; self.called_layoutIfNeeded = YES; } +- (CGRect)caretRectForPosition:(UITextPosition *)position { + return self.test_caretRect; +} + @end diff --git a/Podfile b/Podfile index fc54f04..d0fa888 100644 --- a/Podfile +++ b/Podfile @@ -1,10 +1,19 @@ -platform :ios, "7.0" +platform :ios, "9.0" -target "AutoLayoutTextViews" do +workspace "AutoLayoutTextViews" +project "AutoLayoutTextViews" +target 'AutoLayoutTextViews' do + use_frameworks! + + target 'AutoLayoutTextViewsTests' do + inherit! :search_paths + pod 'Expecta', '~> 1.0' + pod 'OCMock', '~> 3.1' + end end -target "AutoLayoutTextViewsTests" do - pod 'Expecta', '~> 0.3' - pod 'OCMock', '~> 3.1' +target 'AutoLayoutTextViewsDemo' do + project "AutoLayoutTextViewsDemo/AutoLayoutTextViewsDemo" + pod 'AutoLayoutTextViews', :path => '.' end diff --git a/Podfile.lock b/Podfile.lock index 4e080b0..deb39a9 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,13 +1,22 @@ PODS: - - Expecta (0.3.1) - - OCMock (3.1.1) + - AutoLayoutTextViews (1.2.8) + - Expecta (1.0.6) + - OCMock (3.4) DEPENDENCIES: - - Expecta (~> 0.3) + - AutoLayoutTextViews (from `.`) + - Expecta (~> 1.0) - OCMock (~> 3.1) +EXTERNAL SOURCES: + AutoLayoutTextViews: + :path: . + SPEC CHECKSUMS: - Expecta: 03aabd0a89d8dea843baecb19a7fd7466a69a31d - OCMock: f6cb8c162ab9d5620dddf411282c7b2c0ee78854 + AutoLayoutTextViews: 73a51d16ba0b1fd40aef43977b17d6513146798f + Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5 + OCMock: 35ae71d6a8fcc1b59434d561d1520b9dd4f15765 + +PODFILE CHECKSUM: 4fd1fa3eea9ed4225360b135e612a9fc654c759e -COCOAPODS: 0.34.4 +COCOAPODS: 1.3.1