尝试根据所选的segue路径隐藏另一个视图上的按钮。例如,如果" AddNewPokemon"选择segue,然后在下一个视图页面上显示UIButton.hidden = true。
if segue.identifier == "AddNewPokemon" {
let navigationController = segue.destinationViewController as! UINavigationController
let controller = navigationController.topViewController as! PokedexDetailsViewController
controller.cancelButtonDelegate = self
controller.delegate = self
我曾尝试过去一小时浏览stackoverflow,但无济于事,相当新的swift。
答案 0 :(得分:0)
if segue.identifier == "AddNewPokemon" {
let navigationController = segue.destinationViewController as! UINavigationController
let controller = navigationController.topViewController as! PokedexDetailsViewController
//add line set the value created in PokedexDetailsViewController ie hideButton = true
controller.hideButton = true
controller.cancelButtonDelegate = self
controller.delegate = self
}
在PokedexDetailsViewController控制器中创建一个var hideButton并将其设置为true以准备segue并检查PokedexDetailsViewController viewdidload()方法如果为true则隐藏它。
希望这可以帮助你。
由于