This question is locked. New answers and comments are not allowed.
UITableViewController automatically scrolls to UITextFields within UITableViewCells. This works for cells in which I have normal UITextFields however it does not work with the AutoCompleteTextView which has a UITextField inside a TKView. How can I make this automatic scrolling functionality work for AutoCompleteTextView? I got it working if I scrolled to it manually with the UIKeyboardWillShowNotification but I do not want to accomplish it this way because it will conflict with other code I have for next/previous buttons that scrolls to the next/previous text field.
4 Answers, 1 is accepted
0
Hello Ryan,
The scenario you are describing is a bit specific so it will be a great time saver if you are able to send us a sample project showing the issue. This way we can examine the project and provide a possible solution, which suites your scenario, in short terms.
Thank you for your cooperation.
Regards,
Sophi
Telerik by Progress
The scenario you are describing is a bit specific so it will be a great time saver if you are able to send us a sample project showing the issue. This way we can examine the project and provide a possible solution, which suites your scenario, in short terms.
Thank you for your cooperation.
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
0
Ryan
Top achievements
Rank 1
answered on 30 Aug 2016, 09:53 PM
Unfortunately I cannot provide my source code. It is pretty easily to replicate. Just add TKAutoCompleteTextView to the content view of several UITableViewCells until the table has enough cells so that the keyboard covers the autocomplete field when it is clicked on and notice that it will not automatically scroll as is the standard iOS behavior for UITableViewController.
0
Ryan
Top achievements
Rank 1
answered on 30 Aug 2016, 09:54 PM
This is a standard iOS feature for UITableViewController that is supposed to work for all UITextFields, which is what TKAutoCompleteTextView has inside of its view.
0
Hi Ryan,
We have tried to reproduce the described behavior but UITableViewController seems to work fine with the TKAutoCompleteTextView. The scroll feature is presented both with UITextField and TKAutoCompleteTextView.
The approach I went with is creating a custom cell, derived from UITableViewCell, which has a TKAutoCompleteTextView as a subview. Look the snippet below.
Then in the UITableViewController I am using my custom cell instead of the default UITableViewCell.
In case these snippets do not work on your machine, would you confirm that you are using 2016.1.504 version of TelerikUI?
Regards,
Sophi
Telerik by Progress
We have tried to reproduce the described behavior but UITableViewController seems to work fine with the TKAutoCompleteTextView. The scroll feature is presented both with UITextField and TKAutoCompleteTextView.
The approach I went with is creating a custom cell, derived from UITableViewCell, which has a TKAutoCompleteTextView as a subview. Look the snippet below.
@implementation AutoCmpCell{
TKDataSource *_dataSource;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self){
self.autocmp = [[TKAutoCompleteTextView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 30)];
NSArray *sampleArrayOfStrings =@[@"Kristina Wolfe",@"Freda Curtis",@"Jeffery Francis",@"Eva Lawson", @"Theresa Bryan", @"Jenny Fuller", @"Terrell Norris", @"Eric Wheeler", @"Julius Clayton", @"Alfredo Thornton", @"Roberto Romero",@"Orlando Mathis",@"Eduardo Thomas",@"Harry Douglas"];
_dataSource = [[TKDataSource alloc] initWithArray:sampleArrayOfStrings];
[_dataSource.settings.autocomplete createToken:^TKAutoCompleteToken *(NSUInteger dataIndex, id item) {
TKAutoCompleteToken *token = [[TKAutoCompleteToken alloc] initWithText:item];
return token;
}];
self.autocmp.dataSource = _dataSource;
self.autocmp.backgroundColor = [UIColor purpleColor];
self.autocmp.displayMode = TKAutoCompleteDisplayModePlain;
self.autocmp.suggestMode = TKAutoCompleteSuggestModeAppend;
[self.contentView addSubview:_autocmp];
}
return self;
}
Then in the UITableViewController I am using my custom cell instead of the default UITableViewCell.
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.tableView.dataSource = self;
[self.tableView registerClass:[AutoCmpCell class] forCellReuseIdentifier:@"cell"];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *c = [tableView dequeueReusableCellWithIdentifier:@"cell"];
c.backgroundColor = [UIColor yellowColor];
return c;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 30;
}
@end
In case these snippets do not work on your machine, would you confirm that you are using 2016.1.504 version of TelerikUI?
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