uicontrol

Adding a property to all of my UIControls

試著忘記壹切 提交于 2019-12-11 16:49:33
问题 Im trying to make it so that every single UIControl in my application ( UIButton , UISlider , etc) all have special extra properties that I add to them. I tried to accomplish this by creating a UIControl Category and importing it where needed but I have issues. Here is my code. My setSpecialproperty method gets called but it seems to be getting called in an infinite loop until the app crashes. Can you tell me what Im doing wrong or suggest a smarter way to add a property to all of my

Overriding isHighlighted still changes UIControlState - why?

我只是一个虾纸丫 提交于 2019-12-11 15:55:45
问题 In a UIControl , if I override isHighlighted to set a private _isHighlighted property, and then check the control's state to see if it contains .highlighted , the state still accurately reflects the change. See code below. My question is, how is this possible? I never call super.isHighlighted or manipulate the state property. state is an OptionSet that must have the .highlighted property inserted into the set, which, from what I can determine, does not, or should not, happen if I override the

How to sort order of targets when using UIControl (specifically UIButton)?

心已入冬 提交于 2019-12-11 01:09:03
问题 In my app I have multiple UIButtons for which I add targets. It turns out that the most recently added target is preformed first and then the remaining targets. For example, take this code: [button addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventTouchUpInside]; [button addTarget:self action:@selector(someOtherAction:) forControlEvents:UIControlEventTouchUpInside]; If I would touch up inside button , someOtherAction: would be called before someAction . That's not

How to display a Subclass of UIControl on the screen

扶醉桌前 提交于 2019-12-11 00:37:53
问题 I have created a subclass of UIControl called ToggleImageControl via the following code (with reference to the following post Checkbox image toggle in UITableViewCell) @interface ToggleImageControl : UIControl { BOOL photoIsStarred; UIImageView *imageView; UIImage *normalImage; UIImage *selectedImage; } @property (nonatomic, assign) BOOL photoIsStarred; @property (nonatomic, retain) UIImageView *imageView; @property (nonatomic, retain) UIImage *normalImage; @property (nonatomic, retain)

UIControl subclass is unable to take a target?

孤者浪人 提交于 2019-12-10 17:19:15
问题 I've subclasses UIControl and in it I am sending: [self sendActionsForControlEvents:UIControlEventValueChanged]; When I create an instance of the object, I add a target as follows: [starView addTarget:self action:@selector(starRatingChanged:) forControlEvents:UIControlEventValueChanged]; The view shows up fine, and without the target being there the functionality works well. But with adding the target, it crashes. Any ideas why? My class is declared with: @interface RMStarRating : UIControl {

Custom UIBarButtonItem with quartz

情到浓时终转凉″ 提交于 2019-12-10 16:07:08
问题 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 the whole framework. I just want to draw a custom UIBarButtonItem. Thanks for help. 回答1: If you are using the Three20 library, I guess TTButton's "toolbarButton" style is what you want. TTButton is a sub-class of UIButton, but it allows you to

UIControll in UIScrollView not receiving touch events

筅森魡賤 提交于 2019-12-10 12:55:51
问题 I use SevenSwitch in my project. I need to add it into a UIScrollView but it seems that the control can not receive touch events when I add it into scroll view. I tried sub classing scrollview and overriding below code: - (BOOL)touchesShouldCancelInContentView:(UIView *)view { return NO; } also added: self.scrollView.delaysContentTouches = NO; but still can not receive the touch event. How can I stop scrollview from preventing the UIControl from receiving touches? Update I have a tap gesture

Assign a value to a static text in GUI MATLAB

霸气de小男生 提交于 2019-12-09 14:58:06
问题 How can I assign a value to a static text in a MATLAB GUI? 回答1: Double click on your text in guide to open the property editor, then edit the 'String' property. You can also set the 'Tag' property so you can edit it while your GUI is running. If you set your tag to mytext , you can change the static text to 'MyString' with the following line: set(handles.mytext,'String','MyString') 回答2: So that didn't work for me. However, after setting the tag as above the following would work: set(findobj(

Custom UIControl subclass with RxSwift

那年仲夏 提交于 2019-12-07 11:58:59
问题 I am creating a custom subclass of UIControl (I need to override its draw method) and I want to add RxSwift to bind its isSelected property to my model. So far so good. This works fine. My problem is how can I do to change the value isSelected property in response of user touchUpInside event?. My first try was to use the addTarget method of UIControl, but changing the value of isSelected programmatically is not reported by the ControlProperty (as stated in the doc). But I can figure another

How to distinguish between fired events for a UIButton callback action

我与影子孤独终老i 提交于 2019-12-07 10:15:44
问题 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:) forControlEvents:UIControlEventTouchDown | UIControlEventTouchCancel]; -(void)callback:(UIButton *)button { // need to be able to distinguish between the events if (event == canceled) { } if (event == touchDown) { } ... etc } 回答1: You can change your action to take the event