gpt4 book ai didi

带有后退按钮的快速呈现 Controller 返回上一个屏幕

转载 作者:可可西里 更新时间:2023-11-01 00:55:32 25 4
gpt4 key购买 nike

我正在展示一个 UICollectionViewController,但它最终只是一个没有后退按钮的 Controller ,无法返回到最后一个 Controller 或主 Controller ,我该如何添加后退按钮?或者我还有什么其他选择?

class UserProfileController: UICollectionViewController, UICollectionViewDelegateFlowLayout, UserProfileHeaderDelegate, ProfileHeaderClosedDelegate {


func presentFRC() {
let PE = FriendsRequestsController(collectionViewLayout:
UICollectionViewFlowLayout())
let NPE = UINavigationController(rootViewController: PE)

self.present(NPE, animated: true, completion: nil)
}
}

最佳答案

在您呈现的 View Controller 的 View 中添加以下代码。

override func viewDidLoad() {
super.viewDidLoad()
var backbutton = UIButton(type: .Custom)
backbutton.setImage(UIImage(named: "BackButton.png"), forState: .Normal)
backbutton.setTitle("Back", forState: .Normal)
backbutton.setTitleColor(backbutton.tintColor, forState: .Normal) // You can change the TitleColor
backbutton.addTarget(self, action: "backAction", forControlEvents: .TouchUpInside)

self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backbutton)
}

func backAction() -> Void {
self.navigationController?.popViewControllerAnimated(true)
}

关于带有后退按钮的快速呈现 Controller 返回上一个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49610138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com