如何删除[UITextField setPlaceSearchDelegate:]:这个错误?

时间:2016-10-24 10:07:29

标签: ios objective-c uitextfield

我正在使用此Library进行自动搜索位置

但我收到了错误

 Terminating app due to uncaught exception
 NSInvalidArgumentException', reason: -[UITextField setPlaceSearchDelegate:]: unrecognized selector sent to instance
 0x7faef34e1350'

任何人都可以解决这个错误的原因吗?

试过这段代码: -

#import "ViewController.h"
#import "MVPlaceSearchTextField.h"
#import "AppDelegate.h"
#import <GoogleMaps/GoogleMaps.h>
#import <GooglePlaces/GooglePlaces.h>
#import <GooglePlacePicker/GooglePlacePicker.h>
#import "RightSideViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "SearchResultViewController.h"



@interface ViewController ()<PlaceSearchTextFieldDelegate,UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet MVPlaceSearchTextField *txtPlaceSearch;

@end

@implementation ViewController
@synthesize NearByPropertiesBtn;

- (void)viewDidLoad {
     [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
     self.navigationController.navigationBarHidden = YES;

    _txtPlaceSearch.placeSearchDelegate                 = self;
    _txtPlaceSearch.strApiKey                           = @"AIzaSyB2gYLyy4U36gyTufIPCPwY4N9FQBGqScY";
    _txtPlaceSearch.superViewOfList                     = self.view;  // View, on which Autocompletion list should be appeared.
    _txtPlaceSearch.autoCompleteShouldHideOnSelection   = YES;
    _txtPlaceSearch.maximumNumberOfAutoCompleteRows     = 5;
    _txtPlaceSearch.layer.cornerRadius = 50;


    locationManager = [[CLLocationManager alloc] init];
    [locationManager requestWhenInUseAuthorization];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;

    [locationManager startUpdatingLocation];

}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewDidAppear:(BOOL)animated

{

    //Optional Properties
    _txtPlaceSearch.autoCompleteRegularFontName =  @"HelveticaNeue-Bold";
    _txtPlaceSearch.autoCompleteBoldFontName = @"HelveticaNeue";
    _txtPlaceSearch.autoCompleteTableCornerRadius=0.0;
    _txtPlaceSearch.autoCompleteRowHeight=35;
    _txtPlaceSearch.autoCompleteTableCellTextColor=[UIColor colorWithWhite:0.131 alpha:1.000];
    _txtPlaceSearch.autoCompleteFontSize=14;
    _txtPlaceSearch.autoCompleteTableBorderWidth=1.0;
    _txtPlaceSearch.showTextFieldDropShadowWhenAutoCompleteTableIsOpen=YES;
    _txtPlaceSearch.autoCompleteShouldHideOnSelection=YES;
    _txtPlaceSearch.autoCompleteShouldHideClosingKeyboard=YES;
    _txtPlaceSearch.autoCompleteShouldSelectOnExactMatchAutomatically = YES;
    _txtPlaceSearch.autoCompleteTableFrame = CGRectMake(CGRectGetMinX(_txtPlaceSearch.frame),CGRectGetMaxY(_txtPlaceSearch.frame),_txtPlaceSearch.frame.size.width, 200.0);
    _txtPlaceSearch.layer.cornerRadius = 15;

}
#pragma mark - Place search Textfield Delegates

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

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

}
-(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{
        cell.contentView.backgroundColor = [UIColor whiteColor];
    }
}

0 个答案:

没有答案