This is a migrated thread and some comments may be shown as answers.

AutoCompleteTextView suggestion view not in same view as text field

3 Answers 42 Views
AutoCompleteTextView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan
Top achievements
Rank 1
Ryan asked on 29 Jun 2016, 10:20 PM

Hello, I have a weird issue where the suggestion view is not underneath the UITextField for TKAutoCompleteTextView but rather on top of my telerik SideDrawer for some reason. If I type text inside the UITextField I correctly get all of the suggestions but I can only see them when I open up the telerik Side Drawer navigation. Also my view controller inherits from TKAutoCompleteController and my view controller is inside storyboards with nothing on it, I just instantiate the view controller with the storyboard ID though. Here is the code for how I am displaying the TKAutoCompleteTextView:

-(void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardDidShow:)
                                                 name:UIKeyboardDidShowNotification
                                               object:nil];
     
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardDidHide:)
                                                 name:UIKeyboardDidHideNotification
                                               object:nil];
     
    self.autocomplete = [[TKAutoCompleteTextView alloc] initWithFrame:CGRectMake(10, 70/*self.view.bounds.origin.y + 25*/, self.view.bounds.size.width - 20, 44)];
    self.autocomplete.autoresizingMask =UIViewAutoresizingFlexibleWidth; //| UIViewAutoresizingFlexibleHeight;  //UIViewAutoresizingFlexibleWidth;
    self.view.backgroundColor = [UIColor colorWithRed:0.937 green:0.937 blue:0.957 alpha:1.00];
    self.automaticallyAdjustsScrollViewInsets = NO;
    ;
    self.autocomplete.suggestMode = TKAutoCompleteSuggestModeSuggestAppend;
    //self.autocomplete.suggestMode = TKAutoCompleteSuggestModeSuggest;
    self.autocomplete.textField.placeholder = @"Enter number";
    self.autocomplete.noResultsLabel.text = @"No numbers found";
    [self.autocomplete.closeButton setImage:[UIImage imageNamed:@"clear"] forState:UIControlStateNormal];
    self.autocomplete.imageView.image = [UIImage imageNamed:@"search"];
    self.autocomplete.minimumCharactersToSearch = 1;
    self.autocomplete.suggestionViewHeight = self.view.bounds.size.height - self.view.bounds.origin.y + 45;
    self.autocomplete.dataSource = self;
     
    //self.autocomplete.center = self.view.center;
    [self.autocomplete becomeFirstResponder];
     
    [self.view addSubview:self.autocomplete];
     
    self.view.backgroundColor = [UIColor redColor];
    self.autocomplete.backgroundColor = [UIColor greenColor];
    self.autocomplete.suggestionView.backgroundColor = [UIColor yellowColor];
    //[self.autocomplete addSubview:self.autocomplete.suggestionView];
     
 
}
 
- (void)keyboardDidShow:(NSNotification *) notification
{
    CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
    int height = MIN(keyboardSize.height,keyboardSize.width);
    self.autocomplete.suggestionViewHeight = self.view.bounds.size.height - height - 80;
}
 
- (void)keyboardDidHide:(NSNotification *) notification
{
    self.autocomplete.suggestionViewHeight = self.view.bounds.size.height - 100;
}

3 Answers, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 1
answered on 29 Jun 2016, 10:22 PM

Also the TKAutoCompleteTextView will not show unless I call the line:

[self.view addSubview:self.autocomplete];

but yet in the provided example code this was not called and it still displayed the TKAutoCompleteTextView.

0
Ryan
Top achievements
Rank 1
answered on 29 Jun 2016, 10:29 PM

Just resolved the issue by calling:

[self.view addSubview:self.autocomplete.suggestionView];

 

I would still like my question answered regarding these addSubview calls though. The examples provided did not call that whatsoever. I am running with iOS 9.3.2 on an iPhone 6 as well as iOS 9.3 iPhone 6 simulator.

0
Deyan
Telerik team
answered on 01 Jul 2016, 12:12 PM
Hello Ryan,

Thanks for writing.

We can only guess what the reasons for the undesired behavior are. Although you have solved your problem, we're still willing to answer your questions. The easiest way for us to help will be to take a look at your project and reproduce the case on our side using it.

Can you zip the code and send it to us for further investigation by opening a new support ticket here?

Thanks for your time! 

Regards,
Deyan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AutoCompleteTextView
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or