Skip to content

Commit b51b013

Browse files
committed
Fixed EventKit TextView issue, Fix for UIAlertView, Fix for UITableView
1 parent 222a880 commit b51b013

File tree

8 files changed

+75
-51
lines changed

8 files changed

+75
-51
lines changed

IQKeyboardManager Framework/KeyboardManager.framework/Versions/A/Headers/IQUIView+Hierarchy.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@
6262
*/
6363
- (NSArray*)deepResponderViews;
6464

65-
6665
/*!
6766
@method isInsideSearchBar:
6867
69-
@return returns YES if the receiver object inside of UISearchBar, otherwise return NO.
68+
@return returns YES if the receiver object is UISearchBarTextField, otherwise return NO.
7069
*/
71-
-(BOOL)isInsideSearchBar;
72-
70+
-(BOOL)isSearchBarTextField;
7371

74-
//-(BOOL)isInsideAlertView;
72+
/*!
73+
@method isAlertViewTextField:
74+
75+
@return returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
76+
*/
77+
-(BOOL)isAlertViewTextField;
7578

7679
@end
7780

Binary file not shown.

KeyboardTextFieldDemo/IQKeyBoardManager/IQKeyboardManager.m

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ +(void)load
147147
[[IQKeyboardManager sharedManager] setEnable:YES];
148148
}
149149

150+
//Special TextView
151+
Class EKPlaceholderTextViewClass;
152+
153+
+(void)initialize
154+
{
155+
[super initialize];
156+
157+
EKPlaceholderTextViewClass = NSClassFromString(@"EKPlaceholderTextView");
158+
}
159+
150160
/* Singleton Object Initialization. */
151161
-(id)init
152162
{
@@ -665,7 +675,11 @@ -(void)keyboardWillShow:(NSNotification*)aNotification
665675
//If last restored keyboard size is different(any orientation accure), then refresh. otherwise not.
666676
if (!CGSizeEqualToSize(kbSize, oldKBSize))
667677
{
668-
[self adjustFrame];
678+
//If it is EventKit textView object then let EventKit to adjust it. (Bug ID: #37)
679+
if ([_textFieldView isKindOfClass:EKPlaceholderTextViewClass] == NO)
680+
{
681+
[self adjustFrame];
682+
}
669683
}
670684
}
671685

@@ -687,6 +701,7 @@ -(void)textFieldViewDidEndEditing:(NSNotification*)notification
687701
_textFieldView = nil;
688702
}
689703

704+
690705
/*! UITextFieldTextDidBeginEditingNotification, UITextViewTextDidBeginEditingNotification. Fetching UITextFieldView object. */
691706
-(void)textFieldViewDidBeginEditing:(NSNotification*)notification
692707
{
@@ -730,8 +745,12 @@ -(void)textFieldViewDidBeginEditing:(NSNotification*)notification
730745
topViewBeginRect = rootController.view.frame;
731746
}
732747

733-
// keyboard is already showing. adjust frame.
734-
[self adjustFrame];
748+
//If it is EventKit textView object then let EventKit to adjust it. (Bug ID: #37)
749+
if ([_textFieldView isKindOfClass:EKPlaceholderTextViewClass] == NO)
750+
{
751+
// keyboard is already showing. adjust frame.
752+
[self adjustFrame];
753+
}
735754
}
736755

737756
/* UITextViewTextDidChangeNotificationBug, fix for iOS 7.0.x - http://stackoverflow.com/questions/18966675/uitextview-in-ios7-clips-the-last-line-of-text-string */

KeyboardTextFieldDemo/IQKeyBoardManager/IQUIView+Hierarchy.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@
6262
*/
6363
- (NSArray*)deepResponderViews;
6464

65-
6665
/*!
6766
@method isInsideSearchBar:
6867
69-
@return returns YES if the receiver object inside of UISearchBar, otherwise return NO.
68+
@return returns YES if the receiver object is UISearchBarTextField, otherwise return NO.
7069
*/
71-
-(BOOL)isInsideSearchBar;
72-
70+
-(BOOL)isSearchBarTextField;
7371

74-
//-(BOOL)isInsideAlertView;
72+
/*!
73+
@method isAlertViewTextField:
74+
75+
@return returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
76+
*/
77+
-(BOOL)isAlertViewTextField;
7578

7679
@end
7780

KeyboardTextFieldDemo/IQKeyBoardManager/IQUIView+Hierarchy.m

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@
3535

3636
@implementation UIView (IQ_UIView_Hierarchy)
3737

38+
//Special textFields,textViews,scrollViews
39+
Class UISearchBarTextFieldClass;
40+
Class UIAlertSheetTextFieldClass;
41+
Class UITableViewCellScrollViewClass;
42+
43+
44+
+(void)initialize
45+
{
46+
[super initialize];
47+
48+
UISearchBarTextFieldClass = NSClassFromString(@"UISearchBarTextField");
49+
UIAlertSheetTextFieldClass = NSClassFromString(@"UIAlertSheetTextField");
50+
UITableViewCellScrollViewClass = NSClassFromString(@"UITableViewCellScrollView");
51+
}
52+
3853
-(UIViewController*)viewController
3954
{
4055
UIResponder *nextResponder = self;
@@ -73,7 +88,7 @@ - (UIScrollView*)superScrollView
7388

7489
while (superview)
7590
{
76-
if ([superview isKindOfClass:[UIScrollView class]])
91+
if ([superview isKindOfClass:[UIScrollView class]] && ([superview isKindOfClass:UITableViewCellScrollViewClass] == NO))
7792
{
7893
return (UIScrollView*)superview;
7994
}
@@ -92,7 +107,7 @@ - (NSArray*)responderSiblings
92107
NSMutableArray *tempTextFields = [[NSMutableArray alloc] init];
93108

94109
for (UITextField *textField in siblings)
95-
if ([textField canBecomeFirstResponder] /*&& ![textField isInsideAlertView]*/ && ![textField isInsideSearchBar])
110+
if ([textField canBecomeFirstResponder] && ![textField isAlertViewTextField] && ![textField isSearchBarTextField])
96111
[tempTextFields addObject:textField];
97112

98113
return tempTextFields;
@@ -128,37 +143,15 @@ - (NSArray*)deepResponderViews
128143
return textFields;
129144
}
130145

131-
-(BOOL)isInsideSearchBar
146+
-(BOOL)isSearchBarTextField
132147
{
133-
UIView *superview = self;
134-
135-
while (superview)
136-
{
137-
if ([superview isKindOfClass:[UISearchBar class]])
138-
{
139-
return YES;
140-
}
141-
else superview = superview.superview;
142-
}
143-
144-
return NO;
148+
return [self isKindOfClass:UISearchBarTextFieldClass];
145149
}
146150

147-
//-(BOOL)isInsideAlertView
148-
//{
149-
// UIView *superview = self.superview;
150-
//
151-
// while (superview)
152-
// {
153-
// if ([superview isKindOfClass:[UIAlertView class]])
154-
// {
155-
// return YES;
156-
// }
157-
// else superview = superview.superview;
158-
// }
159-
//
160-
// return NO;
161-
//}
151+
-(BOOL)isAlertViewTextField
152+
{
153+
return [self isKindOfClass:UIAlertSheetTextFieldClass];
154+
}
162155

163156
@end
164157

KeyboardTextFieldDemo/KeyboardTextFieldDemo/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,15 @@
540540
<rect key="frame" x="0.0" y="64" width="320" height="416"/>
541541
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
542542
<subviews>
543-
<searchBar contentMode="redraw" barStyle="black" showsCancelButton="YES" id="Lsj-4F-dUH">
543+
<searchBar contentMode="redraw" barStyle="black" id="Lsj-4F-dUH">
544544
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
545545
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
546546
<textInputTraits key="textInputTraits"/>
547547
<connections>
548548
<outlet property="delegate" destination="dPG-sk-vRY" id="Ogy-4u-RWW"/>
549549
</connections>
550550
</searchBar>
551-
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="YrO-Gs-dk3">
551+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="YrO-Gs-dk3">
552552
<rect key="frame" x="52" y="94" width="217" height="44"/>
553553
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
554554
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>

KeyboardTextFieldDemo/KeyboardTextFieldDemo/IQKeyboard-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<key>CFBundleSignature</key>
2727
<string>????</string>
2828
<key>CFBundleVersion</key>
29-
<string>3.0.4</string>
29+
<string>3.0.5</string>
3030
<key>LSRequiresIPhoneOS</key>
3131
<true/>
3232
<key>UIMainStoryboardFile</key>

KeyboardTextFieldDemo/KeyboardTextFieldDemo/SpecialCaseViewController.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@ @interface SpecialCaseViewController ()<UISearchBarDelegate>
1010

1111
@implementation SpecialCaseViewController
1212

13-
- (void)viewDidLoad
14-
{
15-
[super viewDidLoad];
16-
}
1713
- (IBAction)showAlertClicked:(UIButton *)sender
1814
{
19-
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"IQKeyboardManager" message:@"It doesn't add IQToolbar on UIAlertView & UiSearchBar TextField" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
15+
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];
2016
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
2117
[alertView show];
2218
}
2319

20+
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
21+
{
22+
[searchBar setShowsCancelButton:YES animated:YES];
23+
}
24+
25+
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
26+
{
27+
[searchBar setShowsCancelButton:NO animated:YES];
28+
}
29+
2430
-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
2531
{
2632
[searchBar resignFirstResponder];

0 commit comments

Comments
 (0)