AutocompleteTextfieldSwift icon indicating copy to clipboard operation
AutocompleteTextfieldSwift copied to clipboard

XCode 8/Swift 3 Problems

Open cnpetrich opened this issue 9 years ago • 7 comments

The TableView never appears. I have debugged showing events firing correctly, but I never see any results appear after calling .autoCompleteStrings. Has anyone had any success after upgrading to xCode 8?

cnpetrich avatar Sep 23 '16 05:09 cnpetrich

Hi @cnpetrich , Thanks for reporting this issue. I am currently working for the updates for XCode 8. I will investigate this issue and if confirmed, will provide the fix.

mnbayan avatar Sep 25 '16 15:09 mnbayan

Hi @mnbayan , I am trying to get the tableview in Xcode 8 for Autocomplete textfield but it does not shows me when I set the storyboard for 6s or SE its not showing me subview which is tableview, however if is undone the changes and don't keep the storyboard specific it works.

Have you got the solution over it?

RahulM1987 avatar Oct 04 '16 07:10 RahulM1987

Hi @mnbayan, any update on this? Still no luck from my side.

cnpetrich avatar Oct 07 '16 16:10 cnpetrich

After way too many hours spent troubleshooting and googling, it looks like it's a problem with how subviews are initialized in XCode 8. See here.

You can fix this by modifying setupAutocompleteTable function by adding the two lines below at the beginning of the function:

public func setupAutocompleteTable(_ view:UIView){ self.superview?.layoutIfNeeded() self.layoutIfNeeded() ...

p.s. I hate XCode 8.

cnpetrich avatar Oct 07 '16 18:10 cnpetrich

Hi @cnpetrich. I modify setupAutocompleteTable function as you suggested, and yes - view is displayed, but in my case it appears in wrong place. Strictly speaking it appears above TextField instead of under.

In your project everything is ok?

ghost avatar Oct 12 '16 14:10 ghost

Yes, there were some additional changes I had to make to the function. Here is all of the modified code below. Please try and let me know if it works for you as well:

public func setupAutocompleteTable(_ view:UIView){ self.superview?.layoutIfNeeded() self.layoutIfNeeded() let screenSize = UIScreen.main.bounds.size let tableView = UITableView(frame: CGRect(x: self.frame.origin.x, y: self.frame.origin.y + self.frame.height, width: screenSize.width - (self.frame.origin.x * 2), height: 30.0)) tableView.dataSource = self tableView.delegate = self tableView.rowHeight = autoCompleteCellHeight tableView.isHidden = hidesWhenEmpty ?? true view.addSubview(tableView) autoCompleteTableView = tableView autoCompleteTableHeight = 100.0 }

@Przemex3000

cnpetrich avatar Oct 12 '16 17:10 cnpetrich

Unfortunately your code didn't work in my project -self.frame.origin.y still returns negative values which resulted in view appears in wrong place. I created my own solution - maybe not so good but works. I invoke function setupAutocompleteTable from superclasss when all constraints are set and TextField frame returns correct position.

Thanks for help @cnpetrich

ghost avatar Oct 14 '16 09:10 ghost