No back button in Swift 2

自闭症网瘾萝莉.ら 提交于 2019-12-23 17:26:05

问题


I updated my project to Swift 2.0. When I move from the UITableViewController to the UIViewController, Navigation Item doesn't show back button. Each controller has UINavigationController and I use the show segue.

This code when I move to other controller

  override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.selectRowAtIndexPath(indexPath, animated: true, scrollPosition: UITableViewScrollPosition.None)
        if searchPredicate == nil {
            performSegueWithIdentifier("listenMusic", sender: self)
        } else {
            performSegueWithIdentifier("oneSound", sender: self)
        }
    }

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      if segue.identifier == "listenMusic" {

        if (UIApplication.sharedApplication().delegate as! AppDelegate).mainAudioPlayer != nil {
            if (UIApplication.sharedApplication().delegate as! AppDelegate).mainAudioPlayer.playing {
                (UIApplication.sharedApplication().delegate as! AppDelegate).mainAudioPlayer.stop()
            }
        }
            let playerVC = (segue.destinationViewController as! UINavigationController).topViewController as! PlayMusicViewController

            // variant the second
            let curRow = tableView.indexPathForSelectedRow!.row
            playerVC.arrayOfMP3 = listOfMP3Files
            playerVC.currentRow = curRow
//            println(listOfMP3Files[curRow])
      } else if segue.identifier == "oneSound" {
        if (UIApplication.sharedApplication().delegate as! AppDelegate).mainAudioPlayer != nil {
           if (UIApplication.sharedApplication().delegate as! AppDelegate).mainAudioPlayer.playing {
                (UIApplication.sharedApplication().delegate as! AppDelegate).mainAudioPlayer.stop()
                }
            }
        let playerFromOne = (segue.destinationViewController as! UINavigationController).topViewController as! PlayerFromOneTable
        let currentIndex = tableView.indexPathForSelectedRow!.row
        let currentTrackPass = arraySearchResults[currentIndex]
//        var currentIndexPath = tableView.indexPathForSelectedRow()
        playerFromOne.currentTrack = currentTrackPass
//        NSLog("Current track passs %@", currentTrackPass)
        }
    }

I created new empty project and made simple segue from UIViewController to the second UIViewController and I got the same. I observed that new UIViewController appear from bottom and not from the right side.

来源:https://stackoverflow.com/questions/32650004/no-back-button-in-swift-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!