Skip to content

Commit

Permalink
Workdaround demo added on 'Special Cases' for #88
Browse files Browse the repository at this point in the history
  • Loading branch information
hackiftekhar committed Oct 19, 2014
1 parent a083e56 commit 2fc09b7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
Binary file modified KeyboardTextFieldDemo/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?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 @@ -1417,19 +1416,8 @@
<outlet property="delegate" destination="dPG-sk-vRY" id="Ogy-4u-RWW"/>
</connections>
</searchBar>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="YrO-Gs-dk3">
<rect key="frame" x="52" y="118" width="217" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<state key="normal" title="Show Alert with TextField">
<color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showAlertClicked:" destination="dPG-sk-vRY" eventType="touchUpInside" id="5rA-wP-JUb"/>
</connections>
</button>
<view contentMode="scaleToFill" id="SHK-82-xFg">
<rect key="frame" x="10" y="161" width="305" height="269.99999927522163"/>
<rect key="frame" x="10" y="161" width="305" height="269.99999931523683"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="k8L-Hj-hKb">
Expand Down Expand Up @@ -1468,7 +1456,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.99999952610645" width="285" height="90"/>
<rect key="frame" x="10" y="169.99999955227022" 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 @@ -1567,11 +1555,32 @@
<action selector="switch3Action:" destination="dPG-sk-vRY" eventType="valueChanged" id="CPc-Xs-9c7"/>
</connections>
</switch>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Custom Work" textAlignment="center" minimumFontSize="17" id="2mf-mU-ovU">
<rect key="frame" x="193" y="120" width="123" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="dPG-sk-vRY" id="05U-Nx-aNy"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="YrO-Gs-dk3">
<rect key="frame" x="10" y="120" width="175" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<state key="normal" title="Show Alert with TextField">
<color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showAlertClicked:" destination="dPG-sk-vRY" eventType="touchUpInside" id="5rA-wP-JUb"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="0.81881798910000003" blue="0.7514080219" alpha="1" colorSpace="calibratedRGB"/>
</view>
<navigationItem key="navigationItem" title="Special Cases" id="iYf-Wa-Sqo"/>
<connections>
<outlet property="customWorkTextField" destination="2mf-mU-ovU" id="3GY-QD-LQI"/>
<outlet property="switchEnabled1" destination="Gc0-kK-H9m" id="0HL-Vi-p0F"/>
<outlet property="switchEnabled2" destination="j2n-iP-pDN" id="7cv-Lu-dw6"/>
<outlet property="switchEnabled3" destination="UW7-qN-2eU" id="aHs-TK-eVJ"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

#import "SpecialCaseViewController.h"

@interface SpecialCaseViewController ()<UISearchBarDelegate,UITextFieldDelegate,UITextViewDelegate>
@interface SpecialCaseViewController ()<UISearchBarDelegate,UITextFieldDelegate,UITextViewDelegate,UIGestureRecognizerDelegate>

@end

@implementation SpecialCaseViewController
{
UITapGestureRecognizer *textFieldTapRecognizer;

IBOutlet UITextField *customWorkTextField;

IBOutlet UITextField *textField6;
IBOutlet UITextField *textField7;
IBOutlet UITextField *textField8;
Expand All @@ -26,6 +30,11 @@ -(void)viewDidLoad
{
[super viewDidLoad];

textFieldTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(textFieldTapGestureAction:)];
textFieldTapRecognizer.delegate = self;
[customWorkTextField addGestureRecognizer:textFieldTapRecognizer];


textField6.userInteractionEnabled = switchInteraction1.on;
textField7.userInteractionEnabled = switchInteraction2.on;
textField8.userInteractionEnabled = switchInteraction3.on;
Expand All @@ -37,6 +46,18 @@ -(void)viewDidLoad
[self updateUI];
}

-(void)textFieldTapGestureAction:(UITapGestureRecognizer*)tapRecognized
{
//Do your work on tapping textField.
[[[UIAlertView alloc] initWithTitle:@"IQKeyboardManager" message:@"Do your custom work here" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
//Return YES if it's textFieldTapRecognizer else return NO.
return (gestureRecognizer == textFieldTapRecognizer);
}

- (IBAction)showAlertClicked:(UIButton *)sender
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"IQKeyboardManager" message:@"It doesn't affect UIAlertView (Doesn't add IQToolbar on it's textField" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
Expand Down Expand Up @@ -103,6 +124,12 @@ - (IBAction)switch3Action:(UISwitch *)sender
[self updateUI];
}

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (textField == customWorkTextField) return NO;
else return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
switchEnabled1.enabled = NO;
Expand Down

0 comments on commit 2fc09b7

Please sign in to comment.