How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverController scheme on iPad apps?

后端 未结 15 1556
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 12:36

Problem

In my iPad app, I cannot attach a popover to a button bar item only after press-and-hold events. But this seems to be standard for

15条回答
  •  抹茶落季
    2020-12-07 12:44

    You also can simply do this...

    let longPress = UILongPressGestureRecognizer(target: self, action: "longPress:")
    navigationController?.toolbar.addGestureRecognizer(longPress)
    
    func longPress(sender: UILongPressGestureRecognizer) {
    let location = sender.locationInView(navigationController?.toolbar)
    println(location)
    }
    

提交回复
热议问题