gpt4 book ai didi

swift - BarButtonItem 没有出现

转载 作者:行者123 更新时间:2023-11-28 08:31:51 26 4
gpt4 key购买 nike

我在右侧有一个简单的 + 按钮,用于将行添加到我的 tableView,但是该按钮没有出现。我是这样实现的

    let AddButton = UIButton()
AddButton.setTitle("+", forState: .Normal)
let AddView = UIBarButtonItem(customView: AddButton)
self.navigationItem.rightBarButtonItem = AddView
AddButton.addTarget(self, action: #selector(self.addRow), forControlEvents: UIControlEvents.TouchUpInside)

请注意,我对确实出现的汉堡包按钮使用了完全相同的实现。这是有效的汉堡包按钮实现

    let navicon = UIButton(type: UIButtonType.System)
navicon.setImage(defaultMenuImage(), forState: UIControlState.Normal)
navicon.frame = CGRectMake(0, 0, 30, 30)
let menu = UIBarButtonItem(customView: navicon)
self.navigationItem.leftBarButtonItem = menu
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
navicon.addTarget(self.revealViewController(), action: #selector(SWRevealViewController.revealToggle(_:)), forControlEvents: .TouchUpInside)

为什么会这样?

最佳答案

尝试:

let AddButton = UIButton(type: .Custom)
AddButton.frame = CGRectMake(0, 0, 44, 44)

关于swift - BarButtonItem 没有出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38705442/

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