uicontrol

UIControl - changing assigned selectors: addTarget & removeTarget

冷暖自知 提交于 2019-11-30 07:42:50
问题 I'm using 10 buttons in my interface and need, from time to time, to change the button's selector. Am I required to use: -(void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents before I change the selector or can I just use: -(void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents I'm concerned that if I change the selector using the addTarget: method sans the removeTarget: method that I'll essentially "stack up"

How to disable the highlight control state of a UIButton?

霸气de小男生 提交于 2019-11-29 19:29:01
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? Haydn Your button must have its buttonType set to Custom. In IB you can uncheck "Highlight adjusts image". Programmatically you can use theButton.adjustsImageWhenHighlighted = NO; Similar options are available for the "disabled" state as well. In addition to above answer of unchecking "highlight adjusts image" in IB, make sure that button type is set CUSTOM. This will work for you:

UIControl: sendActionsForControlEvents omits UIEvent

我怕爱的太早我们不能终老 提交于 2019-11-29 07:37:09
I want to implement a custom subclass of UIControl. It works beautifully except for one fatal problem that is making me spit teeth. Whenever I use sendActionsForControlEvents: to send an action message out, it omits to include a UIEvent. For example, if I link it to a method with the following signature: - (IBAction) controlTouched:(id)sender withEvent:(UIEvent *)event ... the event always comes back as nil! The problem seems to occur within sendActionsForControlEvents: Now, I need my IBAction to be able to determine the location of the touch. I usually do so by extracting the touches from the

How to disable the highlight control state of a UIButton?

拜拜、爱过 提交于 2019-11-28 15:02:41
问题 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? 回答1: Your button must have its buttonType set to Custom. In IB you can uncheck "Highlight adjusts image". Programmatically you can use theButton.adjustsImageWhenHighlighted = NO; Similar options are available for the "disabled" state as well. 回答2: In addition to above answer of

How can I mimic a user click to invoke a callback function for a GUI object?

别来无恙 提交于 2019-11-28 03:59:48
问题 I'm trying to programmatically create a click event in MATLAB that will mimic the user clicking on a GUI object. The callback function for the object is a subfunction, so I can't call it directly. However, I am able to get the callback property from the object, which ends up being a 3-by-1 cell array with the following contents: @uiBlockFn/callback_til [ 188.0011] [1x1 struct] How can I invoke this callback function in code such that it mimics what would happen when a user clicks the GUI

UIControl: sendActionsForControlEvents omits UIEvent

二次信任 提交于 2019-11-28 01:35:11
问题 I want to implement a custom subclass of UIControl. It works beautifully except for one fatal problem that is making me spit teeth. Whenever I use sendActionsForControlEvents: to send an action message out, it omits to include a UIEvent. For example, if I link it to a method with the following signature: - (IBAction) controlTouched:(id)sender withEvent:(UIEvent *)event ... the event always comes back as nil! The problem seems to occur within sendActionsForControlEvents: Now, I need my

How to correctly subclass UIControl?

这一生的挚爱 提交于 2019-11-27 17:19:47
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 appropriate action messages. However, inside my UIControl subclass I have to catch touch coordinates, and the only way to do so seems to be overriding these guys: - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { NSLog(@"begin touch track"); return YES; } - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *

How to correctly subclass UIControl?

强颜欢笑 提交于 2019-11-26 18:58:17
问题 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 appropriate action messages. However, inside my UIControl subclass I have to catch touch coordinates, and the only way to do so seems to be overriding these guys: - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { NSLog(@