简体   繁体   English

Swift3 索引 UITableview

[英]Swift3 Indexed UITableview

I know this type of thing has been asked before but any answers I find are either out of date or in Objective C so I think it's worth asking again Writing an app in which I want to show a indexed tableview of contact information.我知道以前有人问过这种类型的事情,但我找到的任何答案要么过时,要么在 Objective C 中,所以我认为值得再问一次 编写一个应用程序,我想在其中显示联系信息的索引表视图。

I've got have an array of NSObject, with properties for code, name, phone and email.我有一个 NSObject 数组,其中包含代码、姓名、电话和电子邮件的属性。 In my viewDidLoad function, I'm loading this array up from a web service no problem and able to display it in the tableview fine.在我的 viewDidLoad 函数中,我从 Web 服务加载这个数组没问题,并且能够在 tableview 中正常显示它。
However dealing with 200+ rows is a little cumbersome so want to add in indexes and sections All the examples I found seem to deal with an array of strings, no one seems to touch on and array of NSObjects.但是处理 200 多行有点麻烦,所以想添加索引和部分 我发现的所有例子似乎都在处理一个字符串数组,似乎没有人涉及 NSObjects 数组。 I've tried adapting the example I found at http://nshipster.com/uilocalizedindexedcollation/ but again seems out of date so haven't succeed.我尝试改编我在http://nshipster.com/uilocalizedindexedcollat​​ion/ 上找到的示例,但似乎又过时了,所以没有成功。

Any help please请任何帮助

I just happened to be researching the same thing.我只是碰巧在研究同样的事情。 Try this demo (no. 36) https://github.com/PrashantMangukiya/SwiftUIDemo by Prashant Mangukiya试试这个演示(第 36 号) https://github.com/PrashantMangukiya/SwiftUIDemo by Prashant Mangukiya

Works for me.为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM