├── .gitignore ├── LICENSE ├── README.md ├── VisibleFormViewController.xcodeproj └── project.pbxproj ├── VisibleFormViewController ├── AppDelegate.h ├── AppDelegate.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m ├── VisibleFormViewController.h ├── VisibleFormViewController.m └── main.m └── picture.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Damien 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VisibleFormViewController 2 | An extended UIviewController allowing to not hide the content behind the keyboard opened. 3 | 4 | ![alt text](https://github.com/damienromito/VisibleFormViewController/blob/master/picture.jpg "Explanations") 5 | 6 | #1 - Extend your UIViewController to VisibleFormViewController 7 | 8 | #import "VisibleFormViewController.h" 9 | 10 | @interface ViewController : VisibleFormViewController 11 | 12 | 13 | #2 - Define the last Visible View 14 | 15 | self.lastVisibleView = label; -------------------------------------------------------------------------------- /VisibleFormViewController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1F9E8A711A716F8100B7C245 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F9E8A691A716F8100B7C245 /* AppDelegate.m */; }; 11 | 1F9E8A721A716F8100B7C245 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1F9E8A6A1A716F8100B7C245 /* Images.xcassets */; }; 12 | 1F9E8A731A716F8100B7C245 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1F9E8A6B1A716F8100B7C245 /* Info.plist */; }; 13 | 1F9E8A741A716F8100B7C245 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F9E8A6C1A716F8100B7C245 /* main.m */; }; 14 | 1F9E8A751A716F8100B7C245 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F9E8A6E1A716F8100B7C245 /* ViewController.m */; }; 15 | 1F9E8A761A716F8100B7C245 /* VisibleFormViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F9E8A701A716F8100B7C245 /* VisibleFormViewController.m */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 1F9E8A381A715DD300B7C245 /* VisibleFormViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VisibleFormViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 1F9E8A681A716F8100B7C245 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 21 | 1F9E8A691A716F8100B7C245 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 22 | 1F9E8A6A1A716F8100B7C245 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 23 | 1F9E8A6B1A716F8100B7C245 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | 1F9E8A6C1A716F8100B7C245 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 25 | 1F9E8A6D1A716F8100B7C245 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 26 | 1F9E8A6E1A716F8100B7C245 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 27 | 1F9E8A6F1A716F8100B7C245 /* VisibleFormViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisibleFormViewController.h; sourceTree = ""; }; 28 | 1F9E8A701A716F8100B7C245 /* VisibleFormViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VisibleFormViewController.m; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 1F9E8A351A715DD300B7C245 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 1F9E8A2F1A715DD300B7C245 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 1F9E8A391A715DD300B7C245 /* Products */, 46 | 1F9E8A671A716F8100B7C245 /* VisibleFormViewController */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 1F9E8A391A715DD300B7C245 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 1F9E8A381A715DD300B7C245 /* VisibleFormViewController.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 1F9E8A671A716F8100B7C245 /* VisibleFormViewController */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 1F9E8A681A716F8100B7C245 /* AppDelegate.h */, 62 | 1F9E8A691A716F8100B7C245 /* AppDelegate.m */, 63 | 1F9E8A6A1A716F8100B7C245 /* Images.xcassets */, 64 | 1F9E8A6B1A716F8100B7C245 /* Info.plist */, 65 | 1F9E8A6C1A716F8100B7C245 /* main.m */, 66 | 1F9E8A6D1A716F8100B7C245 /* ViewController.h */, 67 | 1F9E8A6E1A716F8100B7C245 /* ViewController.m */, 68 | 1F9E8A6F1A716F8100B7C245 /* VisibleFormViewController.h */, 69 | 1F9E8A701A716F8100B7C245 /* VisibleFormViewController.m */, 70 | ); 71 | path = VisibleFormViewController; 72 | sourceTree = ""; 73 | }; 74 | /* End PBXGroup section */ 75 | 76 | /* Begin PBXNativeTarget section */ 77 | 1F9E8A371A715DD300B7C245 /* VisibleFormViewController */ = { 78 | isa = PBXNativeTarget; 79 | buildConfigurationList = 1F9E8A5B1A715DD300B7C245 /* Build configuration list for PBXNativeTarget "VisibleFormViewController" */; 80 | buildPhases = ( 81 | 1F9E8A341A715DD300B7C245 /* Sources */, 82 | 1F9E8A351A715DD300B7C245 /* Frameworks */, 83 | 1F9E8A361A715DD300B7C245 /* Resources */, 84 | ); 85 | buildRules = ( 86 | ); 87 | dependencies = ( 88 | ); 89 | name = VisibleFormViewController; 90 | productName = VisibleInputWhenShowKeyboard; 91 | productReference = 1F9E8A381A715DD300B7C245 /* VisibleFormViewController.app */; 92 | productType = "com.apple.product-type.application"; 93 | }; 94 | /* End PBXNativeTarget section */ 95 | 96 | /* Begin PBXProject section */ 97 | 1F9E8A301A715DD300B7C245 /* Project object */ = { 98 | isa = PBXProject; 99 | attributes = { 100 | LastUpgradeCheck = 0610; 101 | ORGANIZATIONNAME = "Damien Romito"; 102 | TargetAttributes = { 103 | 1F9E8A371A715DD300B7C245 = { 104 | CreatedOnToolsVersion = 6.1.1; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = 1F9E8A331A715DD300B7C245 /* Build configuration list for PBXProject "VisibleFormViewController" */; 109 | compatibilityVersion = "Xcode 3.2"; 110 | developmentRegion = English; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | Base, 115 | ); 116 | mainGroup = 1F9E8A2F1A715DD300B7C245; 117 | productRefGroup = 1F9E8A391A715DD300B7C245 /* Products */; 118 | projectDirPath = ""; 119 | projectRoot = ""; 120 | targets = ( 121 | 1F9E8A371A715DD300B7C245 /* VisibleFormViewController */, 122 | ); 123 | }; 124 | /* End PBXProject section */ 125 | 126 | /* Begin PBXResourcesBuildPhase section */ 127 | 1F9E8A361A715DD300B7C245 /* Resources */ = { 128 | isa = PBXResourcesBuildPhase; 129 | buildActionMask = 2147483647; 130 | files = ( 131 | 1F9E8A731A716F8100B7C245 /* Info.plist in Resources */, 132 | 1F9E8A721A716F8100B7C245 /* Images.xcassets in Resources */, 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXResourcesBuildPhase section */ 137 | 138 | /* Begin PBXSourcesBuildPhase section */ 139 | 1F9E8A341A715DD300B7C245 /* Sources */ = { 140 | isa = PBXSourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 1F9E8A751A716F8100B7C245 /* ViewController.m in Sources */, 144 | 1F9E8A741A716F8100B7C245 /* main.m in Sources */, 145 | 1F9E8A711A716F8100B7C245 /* AppDelegate.m in Sources */, 146 | 1F9E8A761A716F8100B7C245 /* VisibleFormViewController.m in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | 1F9E8A591A715DD300B7C245 /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 158 | CLANG_CXX_LIBRARY = "libc++"; 159 | CLANG_ENABLE_MODULES = YES; 160 | CLANG_ENABLE_OBJC_ARC = YES; 161 | CLANG_WARN_BOOL_CONVERSION = YES; 162 | CLANG_WARN_CONSTANT_CONVERSION = YES; 163 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 164 | CLANG_WARN_EMPTY_BODY = YES; 165 | CLANG_WARN_ENUM_CONVERSION = YES; 166 | CLANG_WARN_INT_CONVERSION = YES; 167 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 168 | CLANG_WARN_UNREACHABLE_CODE = YES; 169 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 170 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 171 | COPY_PHASE_STRIP = NO; 172 | ENABLE_STRICT_OBJC_MSGSEND = YES; 173 | GCC_C_LANGUAGE_STANDARD = gnu99; 174 | GCC_DYNAMIC_NO_PIC = NO; 175 | GCC_OPTIMIZATION_LEVEL = 0; 176 | GCC_PREPROCESSOR_DEFINITIONS = ( 177 | "DEBUG=1", 178 | "$(inherited)", 179 | ); 180 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 181 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 182 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 183 | GCC_WARN_UNDECLARED_SELECTOR = YES; 184 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 185 | GCC_WARN_UNUSED_FUNCTION = YES; 186 | GCC_WARN_UNUSED_VARIABLE = YES; 187 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 188 | MTL_ENABLE_DEBUG_INFO = YES; 189 | ONLY_ACTIVE_ARCH = YES; 190 | SDKROOT = iphoneos; 191 | }; 192 | name = Debug; 193 | }; 194 | 1F9E8A5A1A715DD300B7C245 /* Release */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 199 | CLANG_CXX_LIBRARY = "libc++"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_CONSTANT_CONVERSION = YES; 204 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 205 | CLANG_WARN_EMPTY_BODY = YES; 206 | CLANG_WARN_ENUM_CONVERSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_UNREACHABLE_CODE = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = YES; 213 | ENABLE_NS_ASSERTIONS = NO; 214 | ENABLE_STRICT_OBJC_MSGSEND = YES; 215 | GCC_C_LANGUAGE_STANDARD = gnu99; 216 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 217 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 218 | GCC_WARN_UNDECLARED_SELECTOR = YES; 219 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 220 | GCC_WARN_UNUSED_FUNCTION = YES; 221 | GCC_WARN_UNUSED_VARIABLE = YES; 222 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 223 | MTL_ENABLE_DEBUG_INFO = NO; 224 | SDKROOT = iphoneos; 225 | VALIDATE_PRODUCT = YES; 226 | }; 227 | name = Release; 228 | }; 229 | 1F9E8A5C1A715DD300B7C245 /* Debug */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 233 | INFOPLIST_FILE = "$(SRCROOT)/VisibleFormViewController/Info.plist"; 234 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 235 | PRODUCT_NAME = VisibleFormViewController; 236 | }; 237 | name = Debug; 238 | }; 239 | 1F9E8A5D1A715DD300B7C245 /* Release */ = { 240 | isa = XCBuildConfiguration; 241 | buildSettings = { 242 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 243 | INFOPLIST_FILE = "$(SRCROOT)/VisibleFormViewController/Info.plist"; 244 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 245 | PRODUCT_NAME = VisibleFormViewController; 246 | }; 247 | name = Release; 248 | }; 249 | /* End XCBuildConfiguration section */ 250 | 251 | /* Begin XCConfigurationList section */ 252 | 1F9E8A331A715DD300B7C245 /* Build configuration list for PBXProject "VisibleFormViewController" */ = { 253 | isa = XCConfigurationList; 254 | buildConfigurations = ( 255 | 1F9E8A591A715DD300B7C245 /* Debug */, 256 | 1F9E8A5A1A715DD300B7C245 /* Release */, 257 | ); 258 | defaultConfigurationIsVisible = 0; 259 | defaultConfigurationName = Release; 260 | }; 261 | 1F9E8A5B1A715DD300B7C245 /* Build configuration list for PBXNativeTarget "VisibleFormViewController" */ = { 262 | isa = XCConfigurationList; 263 | buildConfigurations = ( 264 | 1F9E8A5C1A715DD300B7C245 /* Debug */, 265 | 1F9E8A5D1A715DD300B7C245 /* Release */, 266 | ); 267 | defaultConfigurationIsVisible = 0; 268 | defaultConfigurationName = Release; 269 | }; 270 | /* End XCConfigurationList section */ 271 | }; 272 | rootObject = 1F9E8A301A715DD300B7C245 /* Project object */; 273 | } 274 | -------------------------------------------------------------------------------- /VisibleFormViewController/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /VisibleFormViewController/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 22 | //nav.navigationBarHidden = NO; 23 | self.window.rootViewController = [ViewController new]; 24 | [self.window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application { 29 | // 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. 30 | // 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. 31 | } 32 | 33 | - (void)applicationDidEnterBackground:(UIApplication *)application { 34 | // 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. 35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 36 | } 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application { 39 | // 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. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application { 43 | // 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. 44 | } 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /VisibleFormViewController/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /VisibleFormViewController/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | fr.romito.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /VisibleFormViewController/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import "VisibleFormViewController.h" 10 | 11 | @interface ViewController : VisibleFormViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /VisibleFormViewController/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | 12 | @implementation ViewController 13 | 14 | 15 | - (void)loadView 16 | { 17 | [super loadView]; 18 | 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | UITextField * field1 = [UITextField new]; 22 | field1.translatesAutoresizingMaskIntoConstraints = NO; 23 | field1.backgroundColor = [UIColor grayColor]; 24 | field1.layer.cornerRadius = 3; 25 | field1.clipsToBounds = YES; 26 | field1.delegate = self; 27 | [self.view addSubview:field1]; 28 | 29 | UILabel *label = [UILabel new]; 30 | label.translatesAutoresizingMaskIntoConstraints = NO; 31 | label.text = @"The keyboard will never hide this view"; 32 | label.textColor = [UIColor blueColor]; 33 | label.numberOfLines = 0; 34 | [self.view addSubview:label]; 35 | 36 | NSDictionary *views = NSDictionaryOfVariableBindings(field1,label); 37 | 38 | [self.view addConstraints:[NSLayoutConstraint 39 | constraintsWithVisualFormat:@"H:|-[field1]-|" 40 | options: NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom 41 | metrics:0 42 | views:views]]; 43 | 44 | [self.view addConstraints:[NSLayoutConstraint 45 | constraintsWithVisualFormat:@"V:|-300-[field1(44)]-[label]" 46 | options: NSLayoutFormatAlignAllRight | NSLayoutFormatAlignAllLeft 47 | metrics:0 48 | views:views]]; 49 | 50 | //SET THE LAST VIEW WHICH THE KEYBOARD WILL NOT HIDE 51 | self.lastVisibleView = label; 52 | self.visibleMargin = 15.; 53 | 54 | } 55 | 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /VisibleFormViewController/VisibleFormViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // VisibleFormViewController.h 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VisibleFormViewController : UIViewController 12 | 13 | @property (nonatomic, strong) UIView *lastVisibleView; 14 | @property (nonatomic) CGFloat visibleMargin; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /VisibleFormViewController/VisibleFormViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // VisibleFormViewController.m 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import "VisibleFormViewController.h" 10 | 11 | @interface VisibleFormViewController() 12 | @property (nonatomic) CGFloat visibleOffset; 13 | @end 14 | 15 | @implementation VisibleFormViewController 16 | 17 | 18 | - (void)viewWillAppear:(BOOL)animated 19 | { 20 | [super viewWillAppear:animated]; 21 | [[NSNotificationCenter defaultCenter] addObserver:self 22 | selector:@selector(keyboardWillShow:) 23 | name:UIKeyboardWillShowNotification 24 | object:nil]; 25 | 26 | [[NSNotificationCenter defaultCenter] addObserver:self 27 | selector:@selector(keyboardWillHide:) 28 | name:UIKeyboardWillHideNotification 29 | object:nil]; 30 | self.visibleMargin = 10.; 31 | } 32 | 33 | #pragma keyboard height 34 | 35 | - (void) keyboardWillShow:(NSNotification *)note 36 | { 37 | CGRect keyboardBounds; 38 | [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardBounds]; 39 | NSNumber *duration = [note.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey]; 40 | NSNumber *curve = [note.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey]; 41 | 42 | keyboardBounds = [self.view convertRect:keyboardBounds toView:nil]; 43 | CGRect frame = self.view.frame; 44 | CGFloat visibleHeight = frame.size.height - keyboardBounds.size.height ; 45 | CGFloat lastVisiblePointY = self.lastVisibleView.frame.origin.y + self.lastVisibleView.frame.size.height; 46 | if (self.lastVisibleView && self.visibleOffset == 0 && (lastVisiblePointY + self.visibleMargin ) > visibleHeight) { 47 | self.visibleOffset = lastVisiblePointY - visibleHeight + self.visibleMargin ; 48 | frame.origin.y -= self.visibleOffset; 49 | } 50 | 51 | [UIView beginAnimations:nil context:NULL]; 52 | [UIView setAnimationBeginsFromCurrentState:YES]; 53 | [UIView setAnimationDuration:[duration doubleValue]]; 54 | [UIView setAnimationCurve:[curve intValue]]; 55 | 56 | self.view.frame = frame; 57 | 58 | [UIView commitAnimations]; 59 | } 60 | 61 | 62 | - (void) keyboardWillHide:(NSNotification *)note 63 | { 64 | NSNumber *duration = [note.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey]; 65 | NSNumber *curve = [note.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey]; 66 | 67 | CGRect frame = self.view.frame; 68 | frame.origin.y += self.visibleOffset; 69 | self.visibleOffset = 0; 70 | 71 | [UIView beginAnimations:nil context:NULL]; 72 | [UIView setAnimationBeginsFromCurrentState:YES]; 73 | [UIView setAnimationDuration:[duration doubleValue]]; 74 | [UIView setAnimationCurve:[curve intValue]]; 75 | 76 | self.view.frame = frame; 77 | 78 | [UIView commitAnimations]; 79 | } 80 | 81 | 82 | #pragma -mark TextFieldDelegate 83 | 84 | - (BOOL)textFieldShouldReturn:(UITextField *)textField 85 | { 86 | 87 | [self.view endEditing:YES]; 88 | 89 | return YES; 90 | } 91 | 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /VisibleFormViewController/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // VisibleInputWhenShowKeyboard 4 | // 5 | // Created by Damien Romito on 22/01/15. 6 | // Copyright (c) 2015 Damien Romito. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /picture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damienromito/VisibleFormViewController/0bfe9e12380ab93c48c792b21506bf1ee31723a5/picture.jpg --------------------------------------------------------------------------------