如何从自定义 UITabBar 启动模式视图?
我已经从这个 GitHub 位置构建了中心凸起的 UITabBar。
我现在的挑战是我不知道如何创建按下按钮时出现的模式视图。
有人幸运地使用过 idev-recipes RaisingCenterTabBar 吗?您是如何实现那里出现的模式表的?
或者,是否有另一个 gitHub 项目有一个带有模式表的工作自定义选项卡栏?
谢谢你!
I've built out the raised-center UITabBar from this GitHub location.
My challenge now is that I can't figure out how to create a modal view that will appear when the button is pressed.
Has anyone used the idev-recipes RaisedCenterTabBar with luck? How did you implement the modal sheet that appears there?
Alternatively, is there a different gitHub project that has a working custom tab bar with a modal sheet?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我的解决方案,这是迄今为止我发现的最干净的方法...我真的希望它有所帮助,我花了几个小时研究最好的方法。
我设置了一个“UITabBarController”委托,它直接连接到我的故事板上构建的选项卡界面。
** 不要忘记在头文件中包含“tabBarController”委托
** 请注意,此回调方法不是“didSelectViewController”,而是“shouldSelectViewController”。此方法在选择选项卡之前处理请求,这正是您想要的,因此您可以在请求发生之前停止请求...这样您就不必保存当前所在的索引,将其传递并所有这些废话。
然后我只是检查将选择哪个选项卡(基于视图控制器的标题。
**另外:这是我的代码,根据您的代码需要更改它。但原则应该保留。我的“performSegueWithIdentifier”实际上是一个手动segue连接到以模式打开的选项卡控制器。这段代码对我来说非常有用。
Here was my solution, it was BY FAR the cleanest way I found to do this... I really hope it helps, I spent hours researching the best ways.
I setup a "UITabBarController" delegate that connects directly to my tab interface built out on my storyboard.
** Don't forget to include the "tabBarController" delegate in your header file
** Notice this callback method is NOT the "didSelectViewController" but rather the "shouldSelectViewController". This method handles the request before the tab is selected and that is exactly what you want so you can STOP the request before it ever happens... This way you don't have to save the current index you are on, pass it around and all that nonsense.
Then I am simply checking what tab WILL be selected (based on the view controller's title.
** Also: this is my code, change it as needed for your code. But the principals should remain. My "performSegueWithIdentifier" is actually a manual segue connected to my tab controller that opens in a modal. This code is working brilliant for me.
我正在开发的一个程序中有类似的东西,很高兴向您展示我是如何做到的。我在 TabBar 中有几个 viewController。我在我决定首先出现在 ViewDidLoad 屏幕上的任何 VC 中创建我的加号按钮。
我使按钮成为 tabBarController 视图的子视图。后来在这个 VC 的实现中,我有一个名为 scalePicker 的方法:它创建我的其他 VC 之一的实例并以模态方式呈现它。这是代码:(注意:这是我在上面的代码中设置为加号按钮目标的方法)
我希望这对您有帮助,
祝你好运!
I have something similar in a program of mine that I'm working on and would be glad to show you how I do it. I have a couple of viewControllers in a TabBar. I create my Plus button in whichever VC I decide will appear first on the screen in ViewDidLoad.
I make the button a subView of the tabBarController's view. Later on in the implementation of this VC I have a method called scalePicker: which creates and instance of one of my other VC's and presents it modally. Here is the code for that: (note: this is the method that I set as a target for the plus button in the code above)
I hope this helps you,
Good Luck!