Skip to content

Commit

Permalink
Handled Control for Multiple Autocompletion in response of #7
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrugraj committed Oct 31, 2015
1 parent 8e24ff7 commit 04004bc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<customFonts key="customFonts">
<mutableArray key="HelveticaNeue.ttc">
<string>HelveticaNeue</string>
</mutableArray>
</customFonts>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
#import "PlaceObject.h"
#import <GoogleMaps/GoogleMaps.h>

@protocol PlaceSearchTextFieldDelegate <NSObject>
-(void)placeSearchResponseForSelectedPlace:(GMSPlace*)responseDict;
-(void)placeSearchWillShowResult;
-(void)placeSearchWillHideResult;
-(void)placeSearchResultCell:(UITableViewCell*)cell withPlaceObject:(PlaceObject*)placeObject atIndex:(NSInteger)index;
@end
@protocol PlaceSearchTextFieldDelegate;

@interface MVPlaceSearchTextField : MLPAutoCompleteTextField
@property(nonatomic,strong)NSString *strApiKey;

@property(nonatomic,strong)IBOutlet id<PlaceSearchTextFieldDelegate>placeSearchDelegate;
@end

@protocol PlaceSearchTextFieldDelegate <NSObject>

-(void)placeSearch:(MVPlaceSearchTextField*)textField ResponseForSelectedPlace:(GMSPlace*)responseDict;
-(void)placeSearchWillShowResult:(MVPlaceSearchTextField*)textField;
-(void)placeSearchWillHideResult:(MVPlaceSearchTextField*)textField;
-(void)placeSearch:(MVPlaceSearchTextField*)textField ResultCell:(UITableViewCell*)cell withPlaceObject:(PlaceObject*)placeObject atIndex:(NSInteger)index;
@end

Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,22 @@ -(BOOL)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
forAutoCompleteObject:(id<MLPAutoCompletionObject>)autocompleteObject
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if([_placeSearchDelegate respondsToSelector:@selector(placeSearchResultCell:withPlaceObject:atIndex:)]){
[_placeSearchDelegate placeSearchResultCell:cell withPlaceObject:autocompleteObject atIndex:indexPath.row];
if([_placeSearchDelegate respondsToSelector:@selector(placeSearch:ResultCell:withPlaceObject:atIndex:)]){
[_placeSearchDelegate placeSearch:self ResultCell:cell withPlaceObject:autocompleteObject atIndex:indexPath.row];
}else{
cell.contentView.backgroundColor=[UIColor whiteColor];
}
return YES;
}

-(void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField willShowAutoCompleteTableView:(UITableView *)autoCompleteTableView{
if([_placeSearchDelegate respondsToSelector:@selector(placeSearchWillShowResult)]){
[_placeSearchDelegate placeSearchWillShowResult];
if([_placeSearchDelegate respondsToSelector:@selector(placeSearchWillShowResult:)]){
[_placeSearchDelegate placeSearchWillShowResult:self];
}
}
-(void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField willHideAutoCompleteTableView:(UITableView *)autoCompleteTableView{
if([_placeSearchDelegate respondsToSelector:@selector(placeSearchWillHideResult)]){
[_placeSearchDelegate placeSearchWillHideResult];
if([_placeSearchDelegate respondsToSelector:@selector(placeSearchWillHideResult:)]){
[_placeSearchDelegate placeSearchWillHideResult:self];
}
}

Expand All @@ -138,7 +138,7 @@ -(void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField willHideAutoC

-(void)placeDetailForReferance:(NSString *)referance didFinishWithResult:(GMSPlace*)resultDict{
//Respond To Delegate
[_placeSearchDelegate placeSearchResponseForSelectedPlace:resultDict];
[_placeSearchDelegate placeSearch:self ResponseForSelectedPlace:resultDict];
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ -(void)viewDidAppear:(BOOL)animated{
}

#pragma mark - Place search Textfield Delegates
-(void)placeSearchResponseForSelectedPlace:(GMSPlace*)responseDict{

-(void)placeSearch:(MVPlaceSearchTextField*)textField ResponseForSelectedPlace:(GMSPlace*)responseDict{
[self.view endEditing:YES];
NSLog(@"SELECTED ADDRESS :%@",responseDict);
}
-(void)placeSearchWillShowResult{
-(void)placeSearchWillShowResult:(MVPlaceSearchTextField*)textField{

}
-(void)placeSearchWillHideResult{
-(void)placeSearchWillHideResult:(MVPlaceSearchTextField*)textField{

}
-(void)placeSearchResultCell:(UITableViewCell *)cell withPlaceObject:(PlaceObject *)placeObject atIndex:(NSInteger)index{
-(void)placeSearch:(MVPlaceSearchTextField*)textField ResultCell:(UITableViewCell*)cell withPlaceObject:(PlaceObject*)placeObject atIndex:(NSInteger)index{
if(index%2==0){
cell.contentView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
}else{
Expand Down

0 comments on commit 04004bc

Please sign in to comment.