jjochen / JJFloatingActionButton

Floating Action Button for iOS
https://jjochen.github.io/JJFloatingActionButton
MIT License
372 stars 75 forks source link

Action on long press #269

Open Aizaz-Abbasi opened 4 years ago

Aizaz-Abbasi commented 4 years ago

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.

Additional context

jjochen commented 4 years ago

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

Aizaz-Abbasi commented 4 years ago

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 ???

jjochen commented 4 years ago

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.

Aizaz-Abbasi commented 4 years ago

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)
   }

}

jjochen commented 4 years ago

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.

Aizaz-Abbasi commented 4 years ago

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)

atamerdalyan commented 3 years ago

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