我有 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) 中尝试了以下操作,但它对我没有帮助
我使用此代码为不同的设备使用两个 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 上的结果
我在 iPhone 上的结果
最佳答案
感谢 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 模板的屏幕截图...
如果您在代码中实例化 View ,则:
- 获取对主视图 Controller 的导航 Controller 的引用;
- 使用
NSString
字词设置导航 Controller 的标题属性,您希望这些字词出现在“后退”按钮人字形旁边。
顺便说一句,我强烈建议实现自动布局和尺寸类,您可以删除 后退按钮 属性的文本,并让尺寸类为您的后退按钮确定适当的词。
例如,根据问题...
关于ios - 如何在 UISplitViewController 中命名后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31318847/