JJFloatingActionButton icon indicating copy to clipboard operation
JJFloatingActionButton copied to clipboard

Action on long press

Open Aizaz-Abbasi opened this issue 4 years ago • 7 comments

CocoaPods

Describe the bug

I installed the pod its working fine but not on tap on long press. when I long press on it its working fine. how I can change it to action on single tap

thanks for held in advance.

  • JJFloatingActionButton version:
  • iOS version:
  • Xcode version:
  • Is the issue you're experiencing reproducible in the example app?
  • ...no

Additional context

Aizaz-Abbasi avatar Jul 18 '20 13:07 Aizaz-Abbasi

My first guess would be that some UIGestureRecognizer is catching the tap.

jjochen avatar Jul 18 '20 15:07 jjochen

My first guess would be that some UIGestureRecognizer is catching the tap.

There is no UIGestureRecognizer on that view controller. I added UIGestureRecognizer but on another view controller. is it conflicting with UITableView ???

Aizaz-Abbasi avatar Jul 20 '20 06:07 Aizaz-Abbasi

You could try to replace the action button with a regular UIButton and see if the the action is fired on a normal tap. Otherwise I would need to see some example code to debug.

jjochen avatar Jul 20 '20 08:07 jjochen

You could try to replace the action button with a regular UIButton and see if the the action is fired on a normal tap. Otherwise I would need to see some example code to debug.

I checked UIButton s action is fired on tap. Here is my code.

class AllUsersVC: BaseVC, UITableViewDelegate {

var isGroup = false
var uses : [users]!
var inboxMessages : [InboxResponse]!
let actionButton = JJFloatingActionButton()

@IBOutlet weak var myView : UIView!
    
@IBOutlet weak var tableView:UITableView!
let iprogress: iProgressHUD = iProgressHUD()

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.delegate = self
    setGradientBackground()
    
    actionButton.addItem(title: "item 1", image: UIImage(named: "user")?.withRenderingMode(.alwaysTemplate)) { item in
      // do something
    }

    actionButton.addItem(title: "item 2", image: UIImage(named: "user")?.withRenderingMode(.alwaysTemplate)) { item in
      // do something
    }

    actionButton.addItem(title: "item 3", image: nil) { item in
      // do something
    }
    
    actionButton.display(inViewController: self)
    
    DatabaseManager.sharedInstance.getAllChat { (error, inboxMsgs) in
           if inboxMsgs != nil{
               if self.inboxMessages == nil || inboxMsgs?.count != self.inboxMessages.count{
                   
                   self.inboxMessages = inboxMsgs
                   self.view.dismissProgress()
                   self.tableView.reloadData()
               }
              }
           }
    SocketIOManager.sharedInstance.login(message: GlobalVar.userINFO?[0]._id as Any)
    
    
   
}


@IBAction func testBtn(_ sender: Any) {
    print("sdgfg")
}
override func viewWillAppear(_ animated: Bool) {
    iprogress.indicatorStyle = .ballSpinFadeLoader
    iprogress.indicatorSize = 40
    iprogress.captionSize = 10
    iprogress.isShowCaption = false
    iprogress.boxSize = 30
    iprogress.boxColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.714067851)
    iprogress.attachProgress(toView: self.view)
    if inboxMessages == nil{
       view.showProgress()
    }
}

// @objc func showBtn(){ // actionButton.open() // }

}

extension AllUsersVC : UITableViewDataSource ,buttonDelegate{

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
     if inboxMessages == nil{
        return 0
     }
    return inboxMessages.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! AllUsersCell
    cell.delegate = self
    cell.indexPath = indexPath
    cell.nameLbl.text = inboxMessages[indexPath.row].name.capitalizingFirstLetter()
    
    if inboxMessages[indexPath.row].latestMsg != nil{
        if inboxMessages[indexPath.row].latestMsg?.messageType == 1{
                  cell.latestMsgLbl.text = "Image"
        }else if inboxMessages[indexPath.row].latestMsg?.messageType == 2{
                  cell.latestMsgLbl.text = "File"
        }else if inboxMessages[indexPath.row].latestMsg?.isDeleted == 1{
            cell.latestMsgLbl.text = "Message Deleted"
        }else{
            cell.latestMsgLbl.text = inboxMessages[indexPath.row].latestMsg?.message
        }
        cell.timeLbl?.text = getDate(date: (inboxMessages[indexPath.row].latestMsg?.createdAt)!)
    }

    return cell
}

func openChatBtnClick(indexPath: IndexPath) {
    
    if inboxMessages[indexPath.row].members != nil{
               print(inboxMessages[indexPath.row])
               isGroup = true
           }else{
              isGroup = false
           }
       let vc = UIStoryboard.init(name: "App", bundle: Bundle.main).instantiateViewController(withIdentifier: "MessaageVC") as? MessaageVC
       vc?.isGroup = self.isGroup
       self.navigationController?.pushViewController(vc!, animated: true)
   }

}

Aizaz-Abbasi avatar Jul 20 '20 10:07 Aizaz-Abbasi

Maybe you are right, and the table view is somehow causing problems. Is the button a subview of the table view?

[EDIT] saw that it's not.

jjochen avatar Jul 21 '20 13:07 jjochen

Maybe you are right, and the table view is somehow causing problems. Is the button a subview of the table view?

[EDIT] saw that it's not.

Its not subview. I added a view and add button in that but still problem is there.

actionButton.display(inView: myView)

Aizaz-Abbasi avatar Jul 22 '20 05:07 Aizaz-Abbasi

You could try to replace the action button with a regular UIButton and see if the the action is fired on a normal tap. Otherwise I would need to see some example code to debug.

Hi, I have same problem and I have UITAPGestureRecognizer to hide keyboard.... Have you any solution for it??? Thank you

atamerdalyan avatar Jul 15 '21 14:07 atamerdalyan