Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Problem with accept/reject friend request button #19

Closed
n9lvc5 opened this issue Jul 13, 2021 · 3 comments
Closed

Problem with accept/reject friend request button #19

n9lvc5 opened this issue Jul 13, 2021 · 3 comments

Comments

@n9lvc5
Copy link

n9lvc5 commented Jul 13, 2021

This is the same issue as #18 , But the solution was never posted.

From: FriendRequestCell.Swift

private func setupAcceptButton() {
		
		
        acceptButton.translatesAutoresizingMaskIntoConstraints = false
        acceptButton.setTitle("ACCEPT", for: .normal)
        acceptButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 12)
        let gradient = setupGradientLayer()
        gradient.frame = bounds
        acceptButton.layer.insertSublayer(gradient, at: 0)
        acceptButton.tintColor = .white
        acceptButton.layer.cornerRadius = 12
        acceptButton.layer.masksToBounds = true
		

		debugPrint("*** Marker 10")
		acceptButton.addTarget(self, action: #selector( addButtonPressed), for: .touchUpInside)
                 debugPrint("*** Marker 11")
		addSubview(acceptButton)
        let constraints = [
            acceptButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -16),
            acceptButton.bottomAnchor.constraint(equalTo: centerYAnchor),
            acceptButton.widthAnchor.constraint(equalToConstant: 75),
            acceptButton.heightAnchor.constraint(equalToConstant: 20)
        ]
		
        NSLayoutConstraint.activate(constraints)
		//addButtonPressed()
    }

accecpt.addTarget is the issue. Nothing happens when touched.
The syntax seems to correct. The order seems to be correct as well.
I question the location of it, though.
Or is it something simple?

Marker 10 and 11 do show up without error.

@n9lvc5
Copy link
Author

n9lvc5 commented Jul 16, 2021

Found the problem. Seems like iOS 14.5 has changed some rules.

https://developer.apple.com/forums/thread/661508

adding this line to init(style:reuseIdentifier:) made the button respond to tap.

self.contentView.isUserInteractionEnabled = true

hence:

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
   	
   	
       super.init(style: style, reuseIdentifier: reuseIdentifier)
   	self.contentView.isUserInteractionEnabled = true

I'm going to assume that this will also work on the settings view as well.

@n9lvc5 n9lvc5 closed this as completed Jul 16, 2021
@arno608rw
Copy link

fix all button in all cell

@n9lvc5
Copy link
Author

n9lvc5 commented Jul 25, 2021

@arno608rw , I don't understand your comment. Can you please elaborate.

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

No branches or pull requests

2 participants