AutoCompleteTextView suggestion view not in same view as text field

4 posts, 0 answers
  1. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jun 2016

    Posted 29 Jun Link to this post

    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:

        [super viewDidLoad];
        [[NSNotificationCenter defaultCenter] addObserver:self
        [[NSNotificationCenter defaultCenter] addObserver:self
        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 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;

  2. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jun 2016

    Posted 29 Jun in reply to Ryan Link to this post

    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.

  3. DevCraft banner
  4. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jun 2016

    Posted 29 Jun in reply to Ryan Link to this post

    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.

  5. Deyan
    Deyan avatar
    2039 posts

    Posted 01 Jul Link to this post

    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! 

    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
Back to Top
DevCraft banner