This question is locked. New answers and comments are not allowed.
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;
}