UITabBarController 中的 ABPeoplePickerNavigationController 和 UITableViewController
请参阅下面的我自己的答案,我花了几个小时才弄清楚。希望我能为某人节省一些时间。
目前,我的 UI 上有一个按钮,它将以模态方式呈现 ABPeoplePickerNavigationController,效果非常好。我想扩展它来实现收藏夹和最近的内容,这样当用户点击按钮时,我会呈现一个 UITabBarController,其中一个选项卡上有 ABPeoplePickerNavigationController,然后是另外两个带有收藏夹和最近的选项卡(我猜这将是 UITableViewControllers)我基本上希望标签栏控制器的行为就像内置电话应用程序的模式版本,用于联系人、收藏夹和最近选项卡(但不仅仅是电话号码),
我已经进行了全面搜索,试图找到如何解决的问题 。执行此操作(我是 TabBarControllers 的新手),并且到目前为止已尝试以编程方式执行此操作并取得了一些成功,并且在 Interface Builder 中完全没有成功,我所看到的只是一个白屏
是否存在一些库 。已经做了一些与此类似的事情,但我似乎无法找到联系人和收藏夹?
这是我在这两种方法中尝试过的内容及其工作原理的细分:
以编程方式: 我基本上创建了 ABPeoplePickerNavigationController,就像我要单独以模态方式呈现它一样,但使用 setViewControllers 方法将其添加到 UITabBarController 实例。当我呈现此内容时,选项卡上显示“组”,并且我不知道如何将图标更改为联系人的系统图标,或者更改按选项卡栏按钮的行为以不退出组(当您按标签栏按钮时,内置手机应用程序不会备份到该级别)。正如我上面提到的,我基本上希望它的行为与内置的手机应用程序类似,用于联系人、收藏夹和最近的操作。
IB: 我尝试了很多东西,但在尝试以模态方式呈现时总是只得到白屏。
Please see below for my own answer, I figured it out after hours and hours. Hopefully I save someone some time.
I currently have a button on my UI that will modally present an ABPeoplePickerNavigationController, which works perfectly fine. I want to extend this to implement favorites and recents, so that when the user hits the button I present a UITabBarController that has the ABPeoplePickerNavigationController on one tab, and then two other tabs with the favorites and recents (which I'm guessing will be UITableViewControllers. I basically want the tab bar controller to behave like a modal version of the built in phone app for the contacts, favorites and recents tabs (but not for just phone numbers).
I have searched all over trying to get a solution on how to do this (I'm new to TabBarControllers), and have thus far tried to do it programmatically with a little bit of success, and in Interface Builder with absolutely no success, all I ever see is a white screen presented.
Is there some library that already does something close to this that I just can't seem to find for contacts and favorites?
Here is breakdown on what I've tried in both methods, and how it worked:
Programmatically:
I basically create the ABPeoplePickerNavigationController like I was going to present it modally alone, but instead add it to a UITabBarController instance using the setViewControllers method. When I present this, the tab says "Groups" on it, and I can't figure out how to change the icon to the system icon for contacts, or change the behavior of pressing the tab bar button to not back out into the groups (the built in phone app doesn't back up to that level when you press the tab bar button). Like I mentioned above, I basically want it to behave similarly to the built in phone app for contacts, favorites and recents.
IB:
I tried a ton of things and always only get a white screen when trying to present it modally.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有两个选项卡,一个带有 ABPEoplePickerNavigationController,另一个带有昨晚工作的表格视图。我希望这对某人有帮助。请注意,您仍然需要将协议添加到选择器的当前视图控制器和表视图的两个视图控制器,然后将每个协议的委托函数添加到代码中。如果您不知道要采用哪些协议或要编写哪些函数,请查看每个协议的苹果开发文档。
I got two tabs, one with the ABPEoplePickerNavigationController and one with a table view working last night. I hope this helps someone. Note that you still have to add the protocols to the current view controller for the picker and the two for the tableview, and then add the delegate functions for each into your code. If you don't know which protocols to adopt or functions to write, check out the apple dev docs for each.