Questions tagged [uicontrol]

In iOS UIKit, UIControl is the base class for control objects such as buttons and sliders.

Available in iOS 2.0 and later in UIKit. The main role of UIControl is to define an interface and base implementation for preparing action messages and initially dispatching them to their targets when certain events occur.

The UIControl class also includes methods for getting and setting control state—for example, for determining whether a control is enabled or highlighted—and it defines methods for tracking touches within a control. These tracking methods are overridden by UIControl subclasses.

You cannot use the UIControl class directly to instantiate controls. It instead defines the common interface and behavioral structure for all its subclasses.

440 questions
164
votes
14 answers

How to disable the highlight control state of a UIButton?

I've got a UIButton that, when selected, shouldn't change state when being touched. The default behaviour is for it to be in UIControlStateHighlighted while being touched, and this is making me angry. Suggestions?
kbanman
  • 4,223
  • 6
  • 32
  • 40
77
votes
7 answers

How to correctly subclass UIControl?

I don't want UIButton or anything like that. I want to subclass UIControl directly and make my own, very special control. But for some reason, none of any methods I override get ever called. The target-action stuff works, and the targets receive…
HelloMoon
30
votes
9 answers

UIControl Not Receiving Touches

I have a UIControl which implements the touches began method like so: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; //More code goes here This subclass of UIControl is…
Kyle Rosenbluth
  • 1,672
  • 4
  • 22
  • 38
30
votes
4 answers

Can I use custom values of UIControlState for my own control?

Is there a way to set a custom states -- not one of the existing UIControlState values -- for a UIControl? In the UIControlSate enum, there are 16 bits that can be used for custom control states: UIControlStateApplication = 0x00FF0000, …
Mayosse
  • 696
  • 1
  • 7
  • 16
28
votes
2 answers

How to add a custom UIControl class in storyboard?

I have a custom UIControl class that I want to use in my storyboard. I am having problems since there isn't a UIControl in the object library in the Storyboard console. I tried adding a UIView and assigning my custom UIControl class to it, but it…
3254523
  • 3,016
  • 7
  • 29
  • 43
21
votes
3 answers

Highlighting a UIControl subclass

basically I need an image button, specifically a custom object that: 1) calls a controller's action when tapped 2) encapsulates custom data 3) is automatically moved by wrapper view (not relevant) Well, I got all this with a subclass of…
qfwfq
  • 976
  • 11
  • 30
20
votes
2 answers

UIButton not calling action in iOS 5 but works in iOS 6

I have a UIButton that is loaded from a xib file as an IBOutlet property of a view controller. I attach a selector to the button in the viewDidLoad of my view controller: [_myButton addTarget:self action:@selector(mySelector)…
Darren
  • 10,091
  • 18
  • 65
  • 108
16
votes
2 answers

Which is better, setEnabled or setUserInteractionEnabled?

I want to make a UIButton disable for user touch. Both setEnabled and setUserInteractionEnabled can do this. Which is better? How are they different?
Yi Jiang
  • 3,938
  • 6
  • 30
  • 62
14
votes
2 answers

Detect on calloutAccessoryControlTapped only the tap on rightCalloutAccessoryView

My calloutAccessoryControlTapped is also called when I just tap on annotation view and this behavior it's right. But how can I detect if the user has tapped on the right accessory view (in my case a detail disclosure button) and not just in the…
Massimo Polimeni
  • 4,826
  • 4
  • 27
  • 54
14
votes
2 answers

Override UIButton's setEnabled method in Swift

In Swift, UIControl doesn't seem to have a setEnabled: method. Is there a way to detect when the control state was changed?
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
13
votes
2 answers

ios like date/time picker for android platform

I'm building mobile app for both ios and android platform using native ios/android code. And I want apps looks similar. So I need ios style picker (for date and time selection) available in android. I spend half of the day but don't find any sutable…
silent_coder
  • 6,222
  • 14
  • 47
  • 91
12
votes
4 answers

Get tap event for UIButton in UIControl/rotatable view

Edited See the comment section with Nathan for the latest project. There is only problem remaining: getting the right button. Edited I want to have a UIView that the user can rotate. That UIView should contain some UIButtons that can be clicked. I…
J. Doe
  • 12,159
  • 9
  • 60
  • 114
11
votes
3 answers

Assign a value to a static text in GUI MATLAB

How can I assign a value to a static text in a MATLAB GUI?
Achraf
  • 658
  • 6
  • 14
  • 34
10
votes
5 answers

UITextFieldDelegate vs UITextField control events

If I want to handle changes to a UITextField, such as the user typing in it; it seems like this can be done either by assigning a delegate to that text field, and then having the delegate implement shouldChangeCharactersInRange, or by adding a…
GendoIkari
  • 11,734
  • 6
  • 62
  • 104
9
votes
1 answer

UIControl: call-order when adding multiple target-action pairs to the same event?

If I add to a control multiple target-action pairs for the same event, will the control send the action messages to the targets in the same order that I added them? I read the following References but couldn't find an answer. -…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
1
2 3
29 30