Skip to content

Commit

Permalink
Changed deployment target for iOS7, fixed various iOS7 and iOS8 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Ivaniushchenko committed Mar 16, 2015
1 parent 88c1479 commit 55b091e
Show file tree
Hide file tree
Showing 9 changed files with 454 additions and 322 deletions.
4 changes: 2 additions & 2 deletions InputAccessorySample.xcodeproj/project.pbxproj
Expand Up @@ -431,7 +431,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "InputAccessorySample/InputAccessorySample-Prefix.pch";
INFOPLIST_FILE = "InputAccessorySample/InputAccessorySample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -445,7 +445,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "InputAccessorySample/InputAccessorySample-Prefix.pch";
INFOPLIST_FILE = "InputAccessorySample/InputAccessorySample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
38 changes: 18 additions & 20 deletions InputAccessorySample/Base.lproj/Main_iPhone.storyboard
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="Z0S-A9-m09">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="Z0S-A9-m09">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--Master View Controller - Root View Controller-->
<!--Root View Controller-->
<scene sceneID="kQm-7c-VaI">
<objects>
<tableViewController id="aBp-hk-MMX" customClass="NIMasterViewController" sceneMemberID="viewController">
Expand All @@ -23,9 +23,8 @@
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label appearanceType="aqua" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Item1" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7nw-fo-eEy">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Item1" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7nw-fo-eEy">
<rect key="frame" x="20" y="11" width="198" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand All @@ -40,9 +39,8 @@
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label appearanceType="aqua" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Item2" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WpY-Ni-hVc">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Item2" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WpY-Ni-hVc">
<rect key="frame" x="20" y="11" width="198" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand All @@ -57,9 +55,8 @@
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label appearanceType="aqua" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Item3" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RRW-gP-CNC">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Item3" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RRW-gP-CNC">
<rect key="frame" x="20" y="11" width="198" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -106,28 +103,29 @@
<viewControllerLayoutGuide type="top" id="wYf-lU-D2P"/>
<viewControllerLayoutGuide type="bottom" id="DGa-Wf-5Wc"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="KOr-ey-QNQ">
<view key="view" contentMode="scaleToFill" id="KOr-ey-QNQ" customClass="NIDetailViewControllerView">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<tableView appearanceType="aqua" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="cqo-O8-zNH">
<tableView opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="cqo-O8-zNH">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell appearanceType="aqua" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Identifier" id="AWT-eG-q3Y">
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Identifier" id="AWT-eG-q3Y">
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="AWT-eG-q3Y" id="nCb-LM-ezs">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label appearanceType="aqua" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="111" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="FIRST" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="16F-Vj-IEG">
<rect key="frame" x="20" y="11" width="84" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="TXD-5k-PPA">
<rect key="frame" x="20" y="7" width="92" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ip6-rG-6mS">
<rect key="frame" x="129" y="11" width="160" height="22"/>
</imageView>
</subviews>
</tableViewCellContentView>
</tableViewCell>
Expand Down
143 changes: 120 additions & 23 deletions InputAccessorySample/NIDetailViewController.m
Expand Up @@ -9,8 +9,31 @@
#import "NIConversationInputAccessoryView.h"
#import "NIGrowingTextView.h"

@interface NIDetailViewController () <HPGrowingTextViewDelegate, UITableViewDataSource>
@interface NIDetailViewControllerView : UIView

@property (nonatomic, assign) UIViewController *viewController;

@end

@implementation NIDetailViewControllerView

- (void)willMoveToWindow:(UIWindow *)newWindow
{
// if (!newWindow)
// {
// [self.viewController resignFirstResponder];
// [self.viewController.inputAccessoryView resignFirstResponder];
// [self.viewController.inputAccessoryView removeFromSuperview];
// }

[super willMoveToWindow:newWindow];
}

@end

@interface NIDetailViewController () <HPGrowingTextViewDelegate, UITableViewDataSource, UIViewControllerTransitioningDelegate>

@property (nonatomic, strong) IBOutlet UITextField *textField;
@property (nonatomic, strong) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NIConversationInputAccessoryView *customInputAccessoryView;

Expand All @@ -22,16 +45,53 @@ - (void)viewDidLoad
{
[super viewDidLoad];

[self createInputAccessoryView];

NIDetailViewControllerView *view = self.view;
view.viewController = self;

UIEdgeInsets contentInset = self.tableView.contentInset;
contentInset.bottom = kNIGrowingTextViewMinTextViewHeight;
self.tableView.contentInset = contentInset;

self.view.backgroundColor = [UIColor lightGrayColor];
self.tableView.backgroundColor = [UIColor redColor];
self.view.backgroundColor = [UIColor redColor];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:nil];

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
[self.view addGestureRecognizer:tapGestureRecognizer];
// [self.tableView addGestureRecognizer:tapGestureRecognizer];
}

- (void)dealloc
{

}

- (void)hideKeyboard
{
[self.textField resignFirstResponder];

/*
UIView *peripheralHostView = [[self.customInputAccessoryView.window subviews] lastObject];
UIView *inputBackdropView = nil;
for (UIView *subview in peripheralHostView.subviews)
{
if ([NSStringFromClass(subview.class) isEqualToString:@"UIKBInputBackdropView"])
{
inputBackdropView = subview;
break;
}
}
inputBackdropView.frame = peripheralHostView.bounds;
*/
}

- (void)viewWillAppear:(BOOL)animated
Expand All @@ -51,6 +111,39 @@ - (void)viewDidAppear:(BOOL)animated
[self becomeFirstResponder];
}

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

// [self.transitionCoordinator animateAlongsideTransitionInView:self.customInputAccessoryView.superview animation:^(id<UIViewControllerTransitionCoordinatorContext> context)
// {
// [self.inputAccessoryView removeFromSuperview];
// }
// completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
// {
// [self.inputAccessoryView removeFromSuperview];
// }];

__weak __typeof(self) weakSelf = self;

[self.transitionCoordinator notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
// weakSelf.customInputAccessoryView = nil;
// [weakSelf.customInputAccessoryView removeFromSuperview];
//
// [weakSelf reloadInputViews];
}];
}

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

[self.view.window endEditing:YES];

[self resignFirstResponder];
}

#pragma mark - KeyBoard handling

- (void)scrollToLastConversationItem:(BOOL)animated
Expand Down Expand Up @@ -125,18 +218,23 @@ - (void)setTextEntryViewBottomMargin:(CGFloat)aBottomMargin duration:(NSTimeInte
}
};

if (aDuration > 0)
{
[UIView animateWithDuration:aDuration
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState
animations:executionBlock
completion:nil];
}
else
{
executionBlock();
}
// if (aDuration > 0)
// {
// [UIView animateWithDuration:aDuration
// delay:0.0
// options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState
// animations:executionBlock
// completion:nil];
// }
// else
// {
// executionBlock();
// }
}

- (BOOL)canBecomeFirstResponder
{
return YES;
}

- (void)keyboardWillShow:(NSNotification *)notif
Expand All @@ -155,32 +253,30 @@ - (void)keyboardWillHide:(NSNotification *)notif
[self setTextEntryViewBottomMargin:0.f duration:theDuration animationBlock:nil];
}

- (BOOL)canBecomeFirstResponder
{
return YES;
}

- (UIView *)inputAccessoryView
- (void)createInputAccessoryView
{
if (!self.customInputAccessoryView)
{
self.customInputAccessoryView = [[NIConversationInputAccessoryView alloc] initWithFrame:CGRectMake(0.f, 0.f, self.view.bounds.size.width, 44.f)];
self.customInputAccessoryView.textView.delegate = self;
}

}

- (UIView *)inputAccessoryView
{
return self.customInputAccessoryView;
}

#pragma mark HPGrowingTextViewDelegate implementation

- (void)growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView
{
[growingTextView setNeedsLayout];

}

- (void)growingTextViewDidEndEditing:(HPGrowingTextView *)growingTextView
{
[growingTextView resignFirstResponder];

}

- (void)growingTextView:(NIGrowingTextView *)growingTextView willChangeHeight:(float)height
Expand Down Expand Up @@ -210,6 +306,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Identifier"];
cell.backgroundColor = [UIColor greenColor];

UILabel *label = (UILabel *)[cell viewWithTag:111];

Expand Down
Expand Up @@ -36,7 +36,7 @@
@class HPGrowingTextView;
@class HPTextViewInternal;

@protocol HPGrowingTextViewDelegate
@protocol HPGrowingTextViewDelegate <NSObject>

@optional
- (BOOL)growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView;
Expand Down Expand Up @@ -69,7 +69,7 @@
NSTimeInterval animationDuration;

//uitextview properties
__weak NSObject <HPGrowingTextViewDelegate> *delegate;
__weak id <HPGrowingTextViewDelegate> delegate;
NSTextAlignment textAlignment;
NSRange selectedRange;
BOOL editable;
Expand All @@ -93,7 +93,7 @@


//uitextview properties
@property(nonatomic, weak) NSObject<HPGrowingTextViewDelegate> *delegate;
@property(nonatomic, weak) id<HPGrowingTextViewDelegate> delegate;
@property(nonatomic,strong) NSString *text;
@property(nonatomic,strong) UIFont *font;
@property(nonatomic,strong) UIColor *textColor;
Expand Down

0 comments on commit 55b091e

Please sign in to comment.