TKAutoCompleteTextView with storyboards

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

    Posted 30 Jun Link to this post

    Hello,

    I am trying to use storyboards with TKAutoCompleteTextView. I dragged a UIView into my view controller and set the custom class to TKAutoCompleteTextView and connected it to my header file as an IBOutlet but I cannot get the control to show on the screen. How can I accomplish this?

    Here is the code that I have:

    -(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.autoresizingMask =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.textField.placeholder = @"Enter number";
        self.autocomplete.noResultsLabel.text = @"No numbers found";
        [self.autocomplete.closeButton setImage:[UIImage imageNamed:@"clear.png"] forState:UIControlStateNormal];
        self.autocomplete.imageView.image = [UIImage imageNamed:@"search.png"];
        self.autocomplete.minimumCharactersToSearch = 1;
        self.autocomplete.suggestionViewHeight = self.view.bounds.size.height - self.view.bounds.origin.y + 45;
        self.autocomplete.dataSource = self;
        self.autocomplete.delegate = self;
         
        [self.autocomplete becomeFirstResponder];
         
        [self.view addSubview:self.autocomplete];
        [self.view 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. Sophi
    Admin
    Sophi avatar
    99 posts

    Posted 04 Jul Link to this post

    Hi Ryan,

    May I suggest a bit simpler way to show the TKAutoCompleteTextView - why don't you try adding the view programmatically?
    In case there is no particular reason to use storyboards you can just create a new TKAutoCompleteTextView, set the relevant to you settings and add it to the root view. This way you do not need to use storyboards.
    -(void)viewDidLoad
    {
        [super viewDidLoad];  
        this.autocomplete = [[TKAutoCompleteTextView alloc] initWithFrame:CGRectMake(10, self.view.bounds.origin.y,          self.view.bounds.size.width - 20, 44)];
        /// setup autocomplete
     
        [this.view addSubview:this.autocomplete];
    }

    If this suggestion does not work for you, write us back any time.

    Regards,
    Sophi
    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
  3. DevCraft banner
  4. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jun 2016

    Posted 02 Aug in reply to Sophi Link to this post

    I would like the layout to be with storyboards. Developing layout programmatically takes a lot of time when your design may change rapidly and at any instant. Changing it in the storyboard allows for rapid layout changes.
  5. Sophi
    Admin
    Sophi avatar
    99 posts

    Posted 04 Aug Link to this post

    Hello Ryan,

    Our controls are working with C based functions directly for layout. They are not using AutoLayout. Since storyboards are using AutoLayout in the common case you may experience difficulties with storyboard layouts. 

    Unfortunately at this moment the TKAutoCompleteTextView needs more polishing to get smoothly usable with Storyboards. I will recommend using it programmatically, you can still make your layouts dynamic by setting frames depending on parent view's frame or other known dimensions. 

    Regards,
    Sophi
    Telerik by Progress
    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
  6. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jun 2016

    Posted 23 Aug in reply to Sophi Link to this post

    Is storyboard support for telerik iOS controls in development?
  7. Sophi
    Admin
    Sophi avatar
    99 posts

    Posted 29 Aug Link to this post

    Hi Ryan,

    The primary use of our controls is intended to be purely with code meaning you can have a storyboard application but our controls should be added programmatically.
    We do not have Object Library integration, due to this you cannot drag and drop our controls which makes it more convenient to add them in the view hierarchy through the code.

    Regards,
    Sophi
    Telerik by Progress
    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