How to make a UIButton upresponsive - ios

I have a case where I would like to make an already existing UIButton unresponsive and basically act as a UILabel. Doesn't anyone know a way of doing this programmatically in c preferably?

Set it's .userInteractionEnabled property to false

If you disable Interaction still you can see the UIButton blinking for click. Better you can uncheck Enable button property from Accessibility.
:
This will help to achieve your requirement.

You can disable userinteraction on your button something like,
yourButton.userInteractionEnabled = NO;
And your button will not respond more!

Disbale User Intercation by writing this code:
yourButton.userinteractionenabled=NO;

Related

UI Button Connection

I am unable to press the stop recording button, I feel it may have happened after I changed its size because before it was working. I checked my code and the UIbutton is still connected. I am wondering if resizing something can change the configuration for that button.
Well, the button is not supposed to be 'clickable' after the isEnabled is set to false in your viewDidLoad().
You can read more here: https://developer.apple.com/documentation/uikit/uicontrol/1618217-isenabled
You should set isEnabled to true in your viewDidLoad().

How to replace uitextField with uitextView when touching uitextField (swift 2)

My question is how to replace uitextField with uitextView when i touch the uitextField.
What can i do in this situation? i tried to add uitextView and then add uitextField in the same area and when i touch the uitextField it will removed but it doesn't work. my code is
textField.enabled = false
Maybe my code is not right or my idea.
I do this to have Placeholder in UITextView like this video and I thought that this is the best way to have it because i tried many ways but all do not work perfectly.
I need your help guys .
It's the property hidden that you should use and not enabled.
With the latter you can control if the user can interact with the view (enabled = true) or not (enabled = false)
The former instead make the view invisible when set to true and visible otherwise.
What you want is to do this
textField.hidden = true
textView.hidden = false
after the user tap on the textField.
Be sure to have the textView already in the right place where you want it to appear.
You might also want to handle the keyboard :)
Why don't you use a UITextView directly from the beginning?

Stop all UIButtons from working when I tap 1 UIButton swift

I want to make it so that when I tap a UIButton, the rest of buttons are disabled until I click a refresh button.
I have 5 IBOutlets that I want to disable not including the refresh Button. Is there a function that stops the events that I can tie to the rest of the buttons? I don't even know where to start.
Thanks a lot in advance!
Connects a method (IBAction) to the button that must disable other.
Within the method, for each button (connected in the GUI) type the follow line:
button.enabled = false
Hey so I got it to work! I did some more research and there's a duplicate of this post. Everything is explained here:
Disable and Enable UIButton - XCode Swift
Thanks a lot anyways.

Can I make UITextField invisible?

I checked out iPhone: How can I make a UITextField invisible but still clickable?, but the OP has something else going on and the answers didn't seem to help me out of my fix.
I have a UITextField in which the user has to enter text. Instead of the standard UITextField graphic, I want to use a lovely graphic that's been designed for that purpose. The user would still need to be able to enter text and see the text s/he's entering, but I need the textfield to be invisible so that the graphic can show from underneath it.
How can I do this? Or is there another way to do what I'm after?
Adding my comment as an answer. You can try this,
[textField setBackgroundColor:[UIColor clearColor]];
And then set the border style as UITextBorderStyleNone.
something like:
yourTextField.borderStyle = UITextBorderStyleNone;
should do it
Another solution would be hiding the UITextView itself and just adding a transparent button that will call the keyboard to display.
Otherwise, the other answers should work.
Easiest option is to do it in interface builder. Choose the first uitext field style with no border and that's it.

Use UISlider without user interaction

I've got a customized UISlider that I want to use to display information to the user with and I don't want the user to be able to interact with the slider. I've tried
mySlider.enabled = NO;
but the slider becomes greyed out, which does not look the way I want it to look.
So, how do I set a UIControl to disabled without "greying" it out.
mySlider.userInteractionEnabled = NO;
Don't you think it's going to confuse users to present an enabled slider that doesn't respond to touches? A UISlider doesn't just display information, it also tells the user that the information is user-adjustable.
You should come up with your own information display that doesn't look user-adjustable.
userInteractionEnabled probably doesn't works for the UISlider (and why it exists??) but it works for its superview. So, try attaching the UISlider to another auxiliary (transparent?) NSView and then set userInteractionEnabled = NO to this auxiliary view.

Resources