uicontrol

UIControl Not Receiving Touches

允我心安 提交于 2019-12-06 18:35:12
问题 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 instantiated in a view controller, it is then added as a subview to that view controller. I have a breakpoint at the touches began method of the UIControl, and the method never gets called. I've been doing some reading and it seems that the View Controller has

UIControl Subclass - Events called twice

眉间皱痕 提交于 2019-12-06 08:41:16
问题 I'm currently working on a custom UIControl Subclass. To track the touches I use the following Method: - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { NSLog(@"Start"); CGPoint location = [touch locationInView:self]; if ([self touchIsInside:location] == YES) { //Touch Down [self sendActionsForControlEvents:UIControlEventTouchDown]; return YES; } else { return NO; } } This works as expected and @"Start" is loged exactely once. The next step is that I add a Target

Define custom touch area in custom UIControl object

妖精的绣舞 提交于 2019-12-05 21:18:16
I am creating a custom UIControl object as detailed here . It is all working well except for the touch area. I want to find a way to limit the touch area to only part of the control, in the example above I want it to be restricted to the black circumference only rather than the whole control area. Any idea? Cheers You can override UIView's pointInside:withEvent: to reject unwanted touches. Here's a method that checks if the touch occurred in a ring around the center of the view: - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { UITouch *touch = [[event touchesForView:self]

Can NSAttributedString be used to connect native app actions with the words?

旧巷老猫 提交于 2019-12-05 06:48:44
问题 I understand that NSAttributedString can be used for detecting hyperlinks and setting the styling, etc. However, I need certain parts of the string to actually "link" to specific actions in the app. For example, consider the text "this links should open up a native view for [photo 1] and [video 2]" I do not want photo 1 and video 2 to link to the web. i want a new photoviewcontroller to stack on top of the existing navigation stack. Can this be achieved with NSAttributed String? If not, what

UITextFieldDelegate vs UITextField control events

为君一笑 提交于 2019-12-04 18:38:15
问题 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 target to the textField, and handling the UIControlEventEditingChanged event. Aside from the fact that with the delegate method, you can return NO and therefor stop the user from making the edit, is there any difference between these 2 things? Same

How to add touch event for custom uicontrol and controller?

百般思念 提交于 2019-12-04 18:13:22
I have a custom UIControl that has three subviews. Each of those subviews, I add a target: button.addTarget(self, action: #selector(buttonTapped(clickedBtn:)), for: .touchUpInside) Within that function buttonTapped , it does some special animations to do some transitions (It mimics the segmented control). Now, within the ViewController that this custom UIControl exists in must know when it's touched. I created an @IBAction function that interacts with the touch events for the custom UIControl. The problem is, that isn't possible (as far as I know). If I add a target touch event to the subviews

UIControl Subclass - Events called twice

谁都会走 提交于 2019-12-04 14:49:57
I'm currently working on a custom UIControl Subclass. To track the touches I use the following Method: - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { NSLog(@"Start"); CGPoint location = [touch locationInView:self]; if ([self touchIsInside:location] == YES) { //Touch Down [self sendActionsForControlEvents:UIControlEventTouchDown]; return YES; } else { return NO; } } This works as expected and @"Start" is loged exactely once. The next step is that I add a Target and a Selector with UIControlEventTouchDown. [markItem addTarget:self action:@selector(action:)

How to implement range slider in Swift

故事扮演 提交于 2019-12-04 03:36:44
I'm trying to implement Range Slider and I used custom control called NMRangeSlider . But when I use it, the slider doesn't appear at all. Could it be also because it's all written in Objective-C? This is how I've currently implemented it: var rangeSlider = NMRangeSlider(frame: CGRectMake(16, 6, 275, 34)) rangeSlider.lowerValue = 0.54 rangeSlider.upperValue = 0.94 self.view.addSubview(rangeSlider) Michal UPDATE: It did not show to me, because it was all white. So the solution, without using any other framework and sticking with this one - you need to set all the views for all the components

Get tap event for UIButton in UIControl/rotatable view

左心房为你撑大大i 提交于 2019-12-04 02:51:15
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 am having a hard time because I am using a UIControl subclass to make the rotating view and in that subclass I have to disable user interactions on the subviews in the UIControl (to make it spin) which may cause the UIButtons not be tappable. How can I make a UIView that the user can spin and contains clickable UIButtons? This is a link to my project

UITextFieldDelegate vs UITextField control events

折月煮酒 提交于 2019-12-03 12:08:22
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 target to the textField, and handling the UIControlEventEditingChanged event. Aside from the fact that with the delegate method, you can return NO and therefor stop the user from making the edit, is there any difference between these 2 things? Same question for handling the beginning of editing or the ending of editing. It could be done either with the