mnbayan / AutocompleteTextfieldSwift

Simple and straightforward sublass of UITextfield to manage string suggestions
MIT License
290 stars 66 forks source link

how to custom autoCompleteCellWidth? #5

Closed aotian16 closed 9 years ago

aotian16 commented 9 years ago

I can set height with autoCompleteCellHeight, but i can't set width. It's seem that there is no autoCompleteCellWidth?

mnbayan commented 9 years ago

@aotian16 i did not provide autoCompleteCellWidth. The cell width will be based on the tableview width, (notice that there is no delegate method that is called widthForRow:atIndexPath as oppose to heightForRow:atIndexPath) and in this library, the tableview is ALWAYS the same width as the textfield.

aotian16 commented 9 years ago

Thanks for your comment. But in my project, the tableview is the same width as the screen width, not as the textfield. The textfield i use is about half width of screen width.

I fix this in setupTableView method

source like this

let tableView = UITableView(frame: CGRectMake(self.frame.origin.x, self.frame.origin.y + CGRectGetHeight(self.frame), CGRectGetWidth(self.frame), autoCompleteTableHeight))

mnbayan commented 9 years ago

See v1.0.1