Segue使用错误的动画和后退按钮不显示

时间:2016-02-18 18:07:01

标签: iphone swift animation ios9 uistoryboardsegue

我在项目的UINavigationController内使用了UITabBarController。 在UINavigationController内,有一个UICollectionView。在UICollectionView中,点击集合中的项目后,应执行 show segue 以查看某种详细信息页面,您可以从该页面返回或使用不同的其他集合已应用数据过滤器。

作为iOS开发的新手,我努力让事情按照我的意愿行事。即使故事板中的所有segues都设置为show,它们也会以动态动画为动画(从底部而不是从右侧进入)。

也不会出现后退按钮。我在属性检查器中为它设置了文本(我已经知道这些必须在视图中消失了#39;)并且还为所有导航项添加了标题...仍然没有显示它们出现的迹象

这是我的故事板:storyboard

这是我使用的prepareForSegue

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showService" {
        if let indexPath = self.collectionView?.indexPathsForSelectedItems() {
            let object = serviceData[indexPath.last!.row]
            let controller = (segue.destinationViewController as! UINavigationController).topViewController as! ServiceDetailViewController
            controller.serviceItem = object
            controller.callerItem = self.name
            controller.navigationItem.leftItemsSupplementBackButton = true
        }
    }
}

我在我的收藏视图的collectionView:didSelectItemAtIndexPath:中触发了segue:

override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    let cell = self.collectionView?.cellForItemAtIndexPath(indexPath)
    performSegueWithIdentifier("showService", sender: cell)
}

1 个答案:

答案 0 :(得分:1)

问题是你的segue从导航控制器的子节点(“另一个标题”)运行到导航控制器。这不是您在导航界面中构建push / show segue的方式。您需要从导航控制器的子项运行到另一个孩子,即例如到你的“标题”视图控制器。因此,如果(假设)你的push / show segue从“Another Title”运行到“Title”,那么当触发segue时,“Title”视图控制器将被推到与“Another Title”相同的导航控制器堆栈上“查看控制器,因此您将在导航栏和后退按钮中更改标题。