iPhone Slider Sensitivity - iphone

I have custom slider that I use the following touch event to respond to:
[bSlider addTarget:self action:#selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
I find it very difficult to use, it does not respond to touches about 50% of the time. Compared to the volume slider with the music player that works great every time you touch it. Are there any secrets to creating a slider in code that will make it more responsive?

I had the same problem with my custom UISlider and solved it by using a larger "thumb" image with transparency around the outside.
I also had problems with my callback function running slowly and causing the slider to be very laggy and clumsy to use, which I fixed by adding a simple check at the top of the function:
int val = ceil(sliderView.value);
if (val == _lastSliderVal) return;
_lastSliderVal = val;
// .. code to update various display elements based on slider value
After changing both of these, the slider works beautifully.

The problem is the event you are tracking. UIControlEventTouchUpInside means that your -start method will only get called if you lift your finger up while it is still in the bounds of the control, something that's not easy to do on a slider.
What you probably want is UIControlEventTouchUpOutside and/or UIControlEventTouchDragExit, which will call -start either when you lift your finger outside of the control's bounds, or when your finger is dragged from within a control to outside its bounds, respectively.
See the UIControl reference for more info.

Well I tried several things including the suggestions above but never got my slider to work as well as the iPhone volume slider in the music app. The only thing that helped was to add a clear background around the button image to make the touch space larger. That created problems getting the button to slide all the way to the bottom and top of slider that I never completely resolved. Now with OS 3.0 is seems to be working much better.

Related

Swift: Custom Slider (Slide To Unlock style)

I am trying to implement a slider in the known slide to unlock style from older iphones to perform an action inside my swift app. The Slider should change background color and change the text inside while dragging. When the user drags til the end, the thumbView should stick to the right side and wait for a confirmation (some event) coming in to finally present a new view.
The slider should look something like this:
First state
Second state while dragging
Third state after releasing
I have found a few things on the internet but nothing that comes close to what I want to do. How would I go about doing this? My guess would be a combination of views with drag events but I feel like there must be an easier way. Any Ideas?
Maybe a UISlider with a transparent track on a rectangle view with your text and color. You can set your image as the UISlider's thumb and receive events as the value changes and when the user touches and releases it.
You can use that to for example, animate the thumb back to the start when the user releases on any place except the end of the track. Also, you can set the slider's value from 0 to 1 and use it to calculate the color, so it changes smoothly.
When the user releases on the end of the track, you activate the activity indicator and start your process to present the next view....
Even though this is a possibility, I think I'd try doing a custom control using a pan gesture. It'd give you more control and you could for example choose how the thumb image animates when going back to the start on release.... I dont' think you can do that with UISlider's setValue(animated:).

Image animation problems in Unity

I state that I am not very experienced in Unity.
I am working on a project in which I have some pictures. To these images I have added an animation that modifies the viewing scale (x,y,z), in such a way as to obtain a pulsation effect. ("ImageEffectPingPong")
To these same images, however, I added another animation that when the image is clicked, a fade effect is obtained, in such a way as to make the image disappear.("fadeOut_x")
When I go to make transition one of the two animations to the animator, it works as it should. the problem is when I try to merge them.
The ImageEffectPingPong animation is set in loop, while the other is activated by setting a bool to the onclick event.
animator.SetBool($"img_{pos}",true);
This is my animator
I tried a combination like this, but when I hit the first image, the fade works, but I no longer get the "pingpong" effect I want.
So how do i get the pingpong effect and when i click on an image, the fade effect, without losing the pingpong effect on the other images?
PS: to create the first effect I created a single animation that changes the scale of each image at the same time, while for the fade effect, each image has its own animation. Images can disappear following the correct sequence.
Sorry for my bad English, I hope I have explained myself as well as possible, I remain available for any misunderstandings. thank you
in case anyone has the same problem as me, I was able to solve it by adding a layer. In the first layer I run the fade animation, while in the second the pingpong effect. It is important to set the weight of the layer.

objective-c iphone sdk dragging image inside a box

I was thinking of make a slider/joystick but not in a circle but in a line. So I made the image drag able only over the X axis and when it gets to the point where the slider stops i did this :
if(slider.center.x <= 60) {
slider.center = CGPointMake(60, slider.center.y);
}
so it wouldn't get bigger than 60 but i was thinking isn't there a better way to do this? like make a box and setting up something to not drag it outside that box?
Thanks!
I think this method is very good. As far as I know there is no wan to stop dragging in other ways than this.
However there is a control called UISlider. This control does the functionality you would like to have.
You could also use touchesBegan, touchesMoved, and touchesEnded, then add an image behind and detect when touch is less than half image's width (Left) or when it's greater than half (Right)

How to extend a button touch area?

I have an arrow button that I want to keep small but I want the touch area around it to be bigger.
I used the answer from the post Here but it made my button larger.
The problem is that the picture of the button is larger than the size it is presented in. But I thought there must be a way to do it without editing it or adding a transparent button.
Use a custom button with an image with mode "center"(which means that it doesn't resize with the button size and stays always in the center). Then you can make the button as big as you want and the button image always stays in the middle with the same size.
You should be able to do it by extending the button class and overriding the hitTest method. In your version of this method you can expand the area checked to include a buffer area and return the button if the touch happens within it.
A transparent button behind this button would also work and just point that to the method... I suppose you could go about this multiple ways. One should prefer the option that is simplest with the least overhead.

Graphic scrolling in iPhone SDK

I have a graphic that is 3 times the width of an iphone landscape view.
I am trying to auto scroll it so that it appears that it is moving sideways, without using the touchscreen scrolling method.
My aim is to maybe have a button you can press and it moves it left or right across the screen like an animation.
I can deal with everything else but am having trouble finding a solution.
Any example code would be appreciated or even any info on whether it is possible or not.
Thanks. Dave
You can wrap a UIView in an animation block. The animation sweeps the origin value in its frame property from one point to another, over a set period of time.