Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action on long press #269

Open
Aizaz-Abbasi opened this issue Jul 18, 2020 · 7 comments
Open

Action on long press #269

Aizaz-Abbasi opened this issue Jul 18, 2020 · 7 comments
Labels

Comments

@Aizaz-Abbasi
Copy link

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

@jjochen
Copy link
Owner

jjochen commented Jul 18, 2020

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

@Aizaz-Abbasi
Copy link
Author

Aizaz-Abbasi commented Jul 20, 2020

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
Copy link
Owner

jjochen commented Jul 20, 2020

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
Copy link
Author

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
Copy link
Owner

jjochen commented Jul 21, 2020

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
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants