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
4
votes
3 answers

Custom UIBarButtonItem with quartz

How can I draw a button with quartz that has exactly the same style as a UIBarButtonItem. The button should be able to show different colors. I downloaded the Three20 project, but this project is really complex, you'd need a lot of time to overlook…
burki
  • 2,946
  • 6
  • 37
  • 51
4
votes
4 answers

How to distinguish between fired events for a UIButton callback action

When defining a callback for a UIButton I listed several events for the same action In the target I would like to be able to distinguish what event triggered the callback [button addTarget:self action:@selector(callback:)…
Avba
  • 14,822
  • 20
  • 92
  • 192
4
votes
1 answer

What is this button artefact when UIButton is selected?

I'm trying to make a UI Button a toggle button by using this code: - (void)tapButton:(id)sender{ UIButton *button = sender; if (!button.selected){ [self performSelector:@selector(highlight:) withObject:button afterDelay:0.0]; …
circuitlego
  • 3,469
  • 5
  • 22
  • 22
4
votes
2 answers

How can I detect interaction anywhere outside of a UIControl, non-invasively?

I have a custom UIControl which, when tapped, goes into a confirm state and, when tapped again, performs the desired action. I want to have this control go back into its initial state if the user interacts anywhere else on the screen. Is there a…
Hilton Campbell
  • 6,065
  • 3
  • 47
  • 79
4
votes
3 answers

UIControl with transparent background

I have a UIControl subclass. I use the following code the change it's background color: - (void)drawRect:(CGRect)rect { [self.backgroundColor setFill]; UIRectFill([self bounds]); } This works fine for all colors except [UIColor clearColor].…
Hesham
  • 5,294
  • 3
  • 34
  • 48
4
votes
0 answers

Differences in catching touch: UIControl vs UIGestureRecognizer

I have custom class, which has UIView. I want it to do action, when the view is tapped. When i add: [(UIControl*)customClass addTarget:self action:@selector(doAction:) …
Nat
  • 12,032
  • 9
  • 56
  • 103
3
votes
2 answers

iOS: Most suitable control for selecting from two options

I am developing an iOS app in which I need a UIControl that allows the user to select between 2 options and 2 options only. For example, assume I am displaying a form in my app in which the user fills up his personal information like Name, gender,…
sherlock
  • 1,521
  • 2
  • 13
  • 17
3
votes
1 answer

Matlab slider uicontrol: make a slider "loop back" for angles reaching 2pi or zero

I am making a user interface with an input that represents an angle, to be set with uicontrol slider elements. It is expected that angles can wrap around the circle, so I would like that when the user increases the angle past the max value (2pi),…
3
votes
0 answers

How to identify the UIKeyboard predictive text selection action?

I'm working on custom UIControl where I will be opening a keyboard(The custom control is become a first responder). In this case I want to identify or detect the which suggested keyword been selected or tapped on the keyboard, so how can I do this?
Jayachandra A
  • 1,335
  • 1
  • 10
  • 21
3
votes
1 answer

Custom UIControl always sends nil UIEvent objects

I have a class that derives from UIControl in which I monitor the touchesBegan/Moved/Ended/Cancelled events. Within those events I call the same events on both super and next responder like so: [self.nextResponder touchesEnded:touches…
leebert
  • 83
  • 1
  • 6
3
votes
1 answer

Why is the new iOS 14 UIControl action syntax so terrible?

New in iOS 14, we can attach an action handler directly to a UIControl: let action = UIAction(title:"") { action in print("howdy!") } button.addAction(action, for: .touchUpInside) That's cool in its way, but the syntax is…
matt
  • 515,959
  • 87
  • 875
  • 1,141
3
votes
0 answers

Is it possible to relinquish control of UISwitch element even before the user releases his finger?

I have a UISwitch element which shows a alert view controller on toggle. UISwitch *element = [[UISwitch alloc] initWithFrame:CGRectZero]; [element addTarget:self action:@selector(doSomething:) forControlEvents:UIControlEventValueChanged]; …
harshith__
  • 447
  • 3
  • 15
3
votes
2 answers

What is the difference between addTarget(_:action:for:) and sendAction(_:to:for:) UIControl instance methods?

I am subclassing UIControl and as I wanted to set my view controller as the target, I discovered the sendAction method. I can't really figure out the differences between both methods and when their respective usage is more appropriate.
tim
  • 107
  • 1
  • 7
3
votes
1 answer

minWidth setting ignored in flex 3.5?

I've done a bit of a search but couldn't find an answer to this question. For example: sampleComponent.explicitMinWidth = 500; sampleComponent.explicitWidth = 10; Sets the width of the sampleComponent to 10, even though I've set the minimum width…
Rob
  • 26,989
  • 16
  • 82
  • 98
3
votes
2 answers

addTarget:action:forControlEvents: selector syntax when target is nil?

I would like a parent ViewController to handle Target-Actions generated by one of its child ViewControllers. According to the Apple docs this should be possible by setting target to nil and following the responder chain. If you specify nil for the…
MH175
  • 2,234
  • 1
  • 19
  • 35