0

Hey fellow swift lovers,

i am currently working on the feature which is famous from Instagram and Facebook.

As I rebuild Instagram I want to have all the followers suggested in the textfield, when an @ is written

My user can share a post with picture and link users, but currently has to exactly type out the name correctly, whereas I want the app to suggest users who fit the written letters.

I am Using KILabel and the linking to profile and so one works already. I also have already the function to search the database for users which works fine.

But I don't know how I should handle the problem.

Should I use a popUpView or popOverView with Tableviewcells? and how can I let it appear above the screen when I write an @ in the textView as there is no button to be clicked to initiate the new VC?

Do you have any suggestion or link I can work with? I did not find anything helpful yet.

Totally clueless here, any help is really really appreciated.

Thanks in advance

Zash__
  • 293
  • 4
  • 16
  • You can create a tableview after fetching data from server and fill it. for setting its possition, you can use constraints. set bottom anchor of tableview to top anchor of textfield, height anchor to your desire and width anchor to view.width anchor. – sbsr Jun 29 '17 at 14:45
  • Hey thanks for your answer. How do I initiate that the tableview only appears when there is an @ and at least one letter? – Zash__ Jun 29 '17 at 14:54

1 Answers1

0

You can achieve this like below code.

@IBAction func textDidChange(_ sender: UITextField){
    if sender.text.contains("@"){
        self.startSearch(sender.text)
        self.createTable()
    }
}

and connect Editing Changed from "Connection Inspectors"

also check this link Get nth character of a string in Swift programming language to manipulate the text of your textfield eg. remove the @ from the reset of string or check if contains at least 1 letter, ...

sbsr
  • 352
  • 3
  • 9