Skip to content

Commit

Permalink
Added demo for 'preventShowingBottomBlankSpace' #93.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackiftekhar committed Oct 15, 2014
1 parent 0b325ea commit aa3bac7
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 4 deletions.
14 changes: 14 additions & 0 deletions IQKeyBoardManager/IQKeyboardManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ -(instancetype)init
// Registering for keyboard notification.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];

// Registering for textField notification.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldViewDidBeginEditing:) name:UITextFieldTextDidBeginEditingNotification object:nil];
Expand Down Expand Up @@ -617,6 +618,13 @@ -(void)keyboardWillShow:(NSNotification*)aNotification
textFieldViewIntialFrame = _textFieldView.frame;
}

if (CGRectEqualToRect(topViewBeginRect, CGRectZero)) // (Bug ID: #5)
{
// keyboard is not showing(At the beginning only). We should save rootViewRect.
UIViewController *rootController = [[self keyWindow] topMostController];
topViewBeginRect = rootController.view.frame;
}

if (_shouldAdoptDefaultKeyboardAnimation)
{
// Getting keyboard animation.
Expand Down Expand Up @@ -734,6 +742,12 @@ - (void)keyboardWillHide:(NSNotification*)aNotification
// topViewBeginRect = CGRectZero; //Committed due to #82
}

/* UIKeyboardDidHideNotification. So topViewBeginRect can be set to CGRectZero. */
- (void)keyboardDidHide:(NSNotification*)aNotification
{
topViewBeginRect = CGRectZero;
}

#pragma mark - UITextFieldView Delegate methods
/*! UITextFieldTextDidBeginEditingNotification, UITextViewTextDidBeginEditingNotification. Fetching UITextFieldView object. */
-(void)textFieldViewDidBeginEditing:(NSNotification*)notification
Expand Down
6 changes: 6 additions & 0 deletions KeyboardTextFieldDemo/IQKeyboard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
C0EC59DE19D0C11200997FFE /* MainSwift.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0EC59DD19D0C11200997FFE /* MainSwift.storyboard */; };
C0EC59DF19D0C19300997FFE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DD7EA019D0A0C5007604CF /* AppDelegate.swift */; };
C0EC59E019D0C19700997FFE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DD7EA119D0A0C5007604CF /* ViewController.swift */; };
C0F1193A19EEDCD500708D17 /* BottomBlankSpaceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0F1193919EEDCD500708D17 /* BottomBlankSpaceViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -247,6 +248,8 @@
C0EC59D919D0C0EE00997FFE /* NavigationBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavigationBarViewController.swift; path = "IQKeyboardManager Swift/NavigationBarViewController.swift"; sourceTree = "<group>"; };
C0EC59DB19D0C0FB00997FFE /* SpecialCaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SpecialCaseViewController.swift; path = "IQKeyboardManager Swift/SpecialCaseViewController.swift"; sourceTree = "<group>"; };
C0EC59DD19D0C11200997FFE /* MainSwift.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = MainSwift.storyboard; path = "IQKeyboardManager Swift/MainSwift.storyboard"; sourceTree = "<group>"; };
C0F1193819EEDCD500708D17 /* BottomBlankSpaceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BottomBlankSpaceViewController.h; sourceTree = "<group>"; };
C0F1193919EEDCD500708D17 /* BottomBlankSpaceViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BottomBlankSpaceViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -544,6 +547,8 @@
C08B91B819D7558800AF16E7 /* TextSelectionViewController.m */,
C08A654B19DB18C700D255E2 /* ManualToolbarViewController.h */,
C08A654C19DB18C700D255E2 /* ManualToolbarViewController.m */,
C0F1193819EEDCD500708D17 /* BottomBlankSpaceViewController.h */,
C0F1193919EEDCD500708D17 /* BottomBlankSpaceViewController.m */,
C0A25BD219D72AAA009E074D /* TableViewController Example */,
C06579C119D60AAF00DAA3EA /* Settings */,
9DC4CE2E18DAF77300DB2CB0 /* Main.storyboard */,
Expand Down Expand Up @@ -907,6 +912,7 @@
C05BE64419AFB9F4000B332C /* IQBarButtonItem.m in Sources */,
C05BE64819AFB9F4000B332C /* IQNSArray+Sort.m in Sources */,
C05BE64619AFB9F4000B332C /* IQKeyboardManager.m in Sources */,
C0F1193A19EEDCD500708D17 /* BottomBlankSpaceViewController.m in Sources */,
C05BE64D19AFB9F4000B332C /* IQUIView+Hierarchy.m in Sources */,
C06579CB19D60B0400DAA3EA /* NavigationTableViewCell.m in Sources */,
C08B91BB19D7558800AF16E7 /* TextSelectionViewController.m in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,37 @@
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../IQKeyBoardManager/IQKeyboardManager.m"
timestampString = "435086539.997263"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "748"
endingLineNumber = "748"
landmarkName = "-keyboardDidHide:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../IQKeyBoardManager/IQKeyboardManager.m"
timestampString = "435086543.480972"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "735"
endingLineNumber = "735"
landmarkName = "-keyboardWillHide:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="En3-R6-bks">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<development version="5100" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
</dependencies>
Expand Down Expand Up @@ -756,6 +757,35 @@
<segue destination="IHN-1B-3KS" kind="push" id="w9d-sW-tRh"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="bKO-gT-FVG" detailTextLabel="Fyc-dl-ydb" style="IBUITableViewCellStyleSubtitle" id="GbI-Bd-1Ey">
<rect key="frame" x="0.0" y="236" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GbI-Bd-1Ey" id="PHz-9f-kJ7">
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Blank Space between UIKeyboard and UIView handling" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="bKO-gT-FVG">
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="preventShowingBottomBlankSpace" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Fyc-dl-ydb">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="10"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<segue destination="d7w-1F-KeR" kind="push" id="DCc-ZU-0ZJ"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
Expand Down Expand Up @@ -1399,7 +1429,7 @@
</connections>
</button>
<view contentMode="scaleToFill" id="SHK-82-xFg">
<rect key="frame" x="10" y="161" width="305" height="269.99999927522174"/>
<rect key="frame" x="10" y="161" width="305" height="269.99999927522163"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="k8L-Hj-hKb">
Expand Down Expand Up @@ -1438,7 +1468,7 @@
<color key="backgroundColor" red="0.80000001192092896" green="1" blue="0.40000000596046448" alpha="1" colorSpace="calibratedRGB"/>
</view>
<view contentMode="scaleToFill" id="uYv-to-iCC">
<rect key="frame" x="10" y="169.99999952610654" width="285" height="90"/>
<rect key="frame" x="10" y="169.99999952610645" width="285" height="90"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" tag="102" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="TextField 4" minimumFontSize="17" id="yDj-sx-3pn">
Expand Down Expand Up @@ -1753,6 +1783,62 @@
</objects>
<point key="canvasLocation" x="-2947" y="233"/>
</scene>
<!--Bottom Blank Space-->
<scene sceneID="aFm-eY-zW9">
<objects>
<viewController automaticallyAdjustsScrollViewInsets="NO" id="d7w-1F-KeR" customClass="BottomBlankSpaceViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="bmd-lQ-cDH">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="ojB-HV-2fF">
<rect key="frame" x="10" y="65" width="250" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<state key="normal" title="preventShowingBottomBlankSpace">
<color key="titleColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" id="Fn3-DC-Psg">
<rect key="frame" x="268" y="65" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="tintColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
<color key="onTintColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
<connections>
<action selector="preventSwitchAction:" destination="d7w-1F-KeR" eventType="valueChanged" id="QgW-L0-WzK"/>
</connections>
</switch>
<textField opaque="NO" clipsSubviews="YES" tag="103" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" id="W77-o3-SvL">
<rect key="frame" x="20" y="515" width="280" height="30"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" keyboardType="URL"/>
</textField>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Here is a textField below this text" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" minimumScaleFactor="0.10000000149011612" id="YEI-pJ-bG7">
<rect key="frame" x="20" y="553" width="284" height="15"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" tag="104" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" id="XL0-UQ-urL">
<rect key="frame" x="20" y="598" width="280" height="30"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField>
</subviews>
<color key="backgroundColor" red="1" green="0.81881798910000003" blue="0.7514080219" alpha="1" colorSpace="calibratedRGB"/>
</view>
<navigationItem key="navigationItem" title="Bottom Blank Space" id="mfb-Pl-Awn"/>
<connections>
<outlet property="switchPreventShowingBottomBlankSpace" destination="Fn3-DC-Psg" id="qQE-CY-yuT"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yRy-ga-2vx" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1263" y="234"/>
</scene>
</scenes>
<resources>
<image name="settings.png" width="25" height="25"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// BottomBlankSpaceViewController.h
// IQKeyboard
//
// Created by Iftekhar on 15/10/14.
// Copyright (c) 2014 Iftekhar. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BottomBlankSpaceViewController : UIViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// BottomBlankSpaceViewController.m
// IQKeyboard
//
// Created by Iftekhar on 15/10/14.
// Copyright (c) 2014 Iftekhar. All rights reserved.
//

#import "BottomBlankSpaceViewController.h"
#import "IQKeyboardManager.h"

@implementation BottomBlankSpaceViewController
{
IBOutlet UISwitch *switchPreventShowingBottomBlankSpace;
}

-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

switchPreventShowingBottomBlankSpace.on = [[IQKeyboardManager sharedManager] preventShowingBottomBlankSpace];
}

- (IBAction)preventSwitchAction:(UISwitch *)sender
{
[[IQKeyboardManager sharedManager] setPreventShowingBottomBlankSpace:switchPreventShowingBottomBlankSpace.on];
}

@end
Loading

0 comments on commit aa3bac7

Please sign in to comment.