【问题标题】:How to be able to respond to a tap on a navigation item title?如何能够响应对导航项标题的点击?
【发布时间】:2018-11-25 17:15:14
【问题描述】:

当您点击标题时,我想添加一个类似于 UITapGesture 的东西,它会转到另一个控制器。我认为 UITapGesture 仅适用于 UIView,但我希望它适用于文本(字符串)。

@objc func checkIfUserIsLoggedIn(){
    if Auth.auth().currentUser?.uid == nil {
        perform(#selector(viewController.handleLogout), with: nil, afterDelay: 0)
    } else {
        let uid = Auth.auth().currentUser?.uid
        Database.database().reference().child("Users").child(uid!).observe(.value, with: { (snapshot) in
            if let dictionary = snapshot.value as?[String : AnyObject] {
                self.navigationItem.title = dictionary["Full Name"] as? String
            }
        }, withCancel: nil)
    }
}

【问题讨论】:

  • 你是说点击导航项中的标题吗?
  • 是的,我想点击标题将我转移到另一个控制器

标签: ios swift uinavigationitem


【解决方案1】:

最简单的解决方案是使用UINavigationItemtitleView 属性而不是title。将UIButton 用于titleView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-07
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多