Open boazin opened 9 years ago
hello, yes, using custom xib files for the tableViewCell(s) is possibile. Even if the demo won't build, you should take a look at the following MLPAutoCompleteTextField's methods:
(void)registerAutoCompleteCellClass:(Class)cellClass forCellReuseIdentifier:(NSString *)reuseIdentifier
(void)registerAutoCompleteCellNib:(UINib *)nib forCellReuseIdentifier:(NSString *)reuseIdentifier
in the MLPAutoCompleteTextField/MLPAutoCompleteTextField.m file
Also, take a look at the DEMOViewController and DEMOCustomAutoCompleteCell classes.
This one I did find, and here's exactly where I got complicated.
Usually when I have a UITableView
the cellForRowAtIndexPath
has something like:
MyCell *cell = (SnackCell *)[tableView dequeueReusableCellWithIdentifier:@"myCellID"];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"myCellID" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
How do I incorporate this concept into registerAutoCompleteCellNib
(it constantly kept crashing)
Thanks for the help - love the package
I'll elaborate. I have a text and an image. The image is downloaded async via SDWebImage It's size is unknown - and I want to "resize" it after download. Couldn't do it so far with the default UIImageView. A possible solution is a custom cell (As discussed in https://github.com/rs/SDWebImage/issues/30) But I got in trouble when trying to add my xib (with it's "attached" class)
A point to the direction (or a demo with xib) will be appreciated
If you need to use a custom UITableViewCell with the MLPAutoCompleteTextField, you just need to define which Cell Class and Cell xib you want to use.
In your ViewController (where you're using the MLPAutoCompleteTextField instance), usually (but not necessarily) inside the - (void)viewDidLoad
method, you just need to call the methods previously mentioned:
(void)registerAutoCompleteCellClass:(Class)cellClass forCellReuseIdentifier:(NSString *)reuseIdentifier
and
(void)registerAutoCompleteCellNib:(UINib *)nib forCellReuseIdentifier:(NSString *)reuseIdentifier
Example:
for example's sake, let's suppose that:
@property (weak, nonatomic) IBOutlet MLPAutoCompleteTextField *searchField;
in your view controller's viewDidLoad method you'll have:
- (void)viewDidLoad
{
[super viewDidLoad];
[_searchField registerClass:[MyCustomCell class]
forCellReuseIdentifier:@"MyCustomCell"];
[_searchField registerAutoCompleteCellNib:[UINib nibWithNibName:@"MyCustomCell" bundle:nil]
forCellReuseIdentifier:@"MyCustomCell"];
}
Is it supported? I'm having trouble with it...