【问题标题】:Presenting a new View Controller Keeping Tab Bar呈现一个新的视图控制器保持标签栏
【发布时间】:2013-11-28 10:48:22
【问题描述】:

我目前正在开发一款支持 iOS6+ 的 iPhone 应用。 应用程序的结构有一个 UITabBarController 作为根控制器,并分配有许多视图控制器。在其中一个选项卡上是一个UITableViewController,其中包含项目的项目列表,使用Push Seque显示该项目的详细视图。

不过,我还有另一个屏幕可以扫描二维码。扫描二维码时,会处理结果以检索一个 id,然后我想显示匹配项目的详细视图页面(如上)。

我可以在 QR 扫描视图控制器中使用以下代码显示它,但这会失去标签栏和导航的任何希望。

[self presentViewController:detailController animated:YES completion:nil];

有什么方法可以呈现详细视图控制器,但仍保留通过 UITableView 路由时获得的标签栏(最好是导航栏)? 到目前为止,我发现的所有内容都引用了 presentModalViewController,但似乎在 iOS6 中已被弃用,取而代之的是 presentViewController。

提前感谢您的任何帮助或建议,

菲尔半

【问题讨论】:

    标签: ios iphone uiviewcontroller uitabbarcontroller


    【解决方案1】:

    模态视图将覆盖所有视图,最终替换 tabBarController、NavigationCONtroller 等...

    Modal view :
    Can works for all view controllers
    Is over all other view and need to be pop programatically (adding a button back manually for example)
    
    Push View :
    Only works in navigation controllers
    Add automatically a back button in the navigationController
    

    我相信您想要的是一个 pushView,它将集成到您的 navigationController 中:

    [self.navigationController pushViewController:viewController animated:YES];
    

    【讨论】:

    • 我试过 [self.navigationController pushViewController...],但它没有做任何事情(没有错误或任何事情)。您对这两种模式的描述帮助我理解了它,我现在已经在我的 QRController 周围包裹了另一个 NavigationController 并且它可以工作!非常感谢。
    • @PhilHalf 我遇到了和你一样的问题。没有错误没有什么。你是怎么解决的?
    【解决方案2】:

    使用这个

    [self.navigationController pushViewController:detailController animated:YES completion:nil];
    

    它将显示详细信息视图,底部有标签栏,顶部有导航栏 如果您不希望顶部的导航栏使用 hide 属性将其隐藏。

    【讨论】:

    • 感谢您的回复。我曾尝试过,但显然误解了导航控制器需要在哪里,但来自 @pull 的描述和 pushViewController 消息有效。
    猜你喜欢
    • 2014-01-16
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多