问题
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