ios - 如何在 UISplitViewController 中命名后退按钮

标签 ios xcode swift ipad uisplitviewcontroller

我有 UITableViewController(它的名字是 News)和 UIViewController(它的名字是 DetailViewController)和 UISplitViewController。当我以纵向使用 iPad 时,我希望它显示后退按钮。我制作了按钮,但无法命名。我写了下面的代码

detailController.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
                detailController.navigationItem.leftItemsSupplementBackButton = true
                detailController.navigationItem.leftBarButtonItem?.title = navigationController?.topViewController.title

但它不显示按钮的名称。我只看到箭头(箭头有效)。

我还在我的 UITableViewController(News) 中尝试了以下操作,但它对我没有帮助

enter image description here

我使用此代码为不同的设备使用两个 segue。

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
        var screen = UIScreen.mainScreen().currentMode?.size.height
        if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad) || screen >= 2000 && UIDevice.currentDevice().orientation.isLandscape == true  && (UIDevice.currentDevice().userInterfaceIdiom == .Phone){
            performSegueWithIdentifier("showDetailParse", sender: nil)
            self.dismissViewControllerAnimated(true, completion: nil)
        } else if (UIDevice.currentDevice().userInterfaceIdiom == .Phone) {
            performSegueWithIdentifier("showParse", sender: nil)
        }
    }

我在 iPad 上的结果 enter image description here

我在 iPhone 上的结果 enter image description here

最佳答案

感谢 Paul Hegarty 和他在斯坦福大学的宝贵讲座,并在 iTunes U 上提供...在这种情况下,他 2013 年的讲座标题为 "Developing iOS 7 Apps for iPhone and iPad"特别是“第 11 课表格 View 和 iPad”。

如果您使用 Storyboard,则:

  • 打开主 Storyboard并选择链接到 Split View Controller 组中的 Master View Controller 的 Navigation Controller;
  • 打开检查器;
  • View Controller 标题下,针对属性 Title,输入您希望在“后退”按钮 V 形旁边显示的字词。

查看使用 Split View Controller 设置的 Master Detail Xcode 模板的屏幕截图...

Interface Building screenshot detailing location of "Title" property for Navigation Controller

如果您在代码中实例化 View ,则:

  • 获取对主视图 Controller 的导航 Controller 的引用;
  • 使用 NSString 字词设置导航 Controller 的标题属性,您希望这些字词出现在“后退”按钮人字形旁边。

顺便说一句,我强烈建议实现自动布局和尺寸类,您可以删除 后退按钮 属性的文本,并让尺寸类为您的后退按钮确定适当的词。

例如,根据问题...

remove text in the "Back Button" property

关于ios - 如何在 UISplitViewController 中命名后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31318847/

相关文章:

ios - UI 测试 Mach-O 链接器错误

ios - 如何通过 AFNetworking 和 NSUrlSession 调用 SOAP Web 服务

ios - 如何在IOS中同时发送N个请求

iphone - 更改NSDate的时间?

ios - 如何将 UILabel 重新定位在与另一个 UILabel 完全相同的位置

c - 使用 XCode 通过 K&R 学习 C,但错误太多

ios - 如何为 iPhone/iPad 创建纵向 iAd 横幅 View

ios - swift spritekit中解析Nodes位置时出现 fatal error

ios - Firebase 存储 : How to reduce requests? (iOS)

ios - 将 swift 数组解析为有效的 json