Detect iPhone Volume Button Hold? (iOS 8) - objective-c

Is there a way to detect if any of the volume buttons on the iPhone are being held?
I know you can detect if one has been pressed, but I specifically need to know if one is being held down.

That's not really possible, but you can have an approximation starting a timer every time you get a volume button pressed event, since you'll receive multiple events in succession when the button is hold. If every time you restart the timer, when the button is released the timer will get triggered and you can do whatever you want. 0.5 seconds worked for me.

Related

Timer's Tick affects the flow of the program

I have a windows form with 2 timers. One of them controls the scrolling text at the bottom, while the other changes pictures in a PictureBox. The problem is that when the first timer's tick event occurs and changes the picture, the horizontally scrolling text stops for around a tenth of a second and then starts scrolling again. I just need to know a way to avoid that.
Use Application.DoEvents Method inside first timer, read that.

Strange behavior of my app when cursor over a label

I'm experiencing a strange behavior of my app.
Among other objects I have a label which is connected to an IBOutlet currentDate. There is also a formatter involved which takes care that only the current time is shown. There is a timer running in the background which fires every other second.
Everything is working fine so far.
When I move the mouse cursor over the label and leave it there, after a few seconds the apps terminates automatically. applicationWillTerminate is called and the app quits as if I have hit the quit menu. No exception, app quits regularly.
I don't understand why this happens. The app shouldn't do anything when I move the cursor over a label. When I don't move the cursor across that label the app remains running.
Any clues what's going on?
Greetings, Ronald

Touch detection without event processing

I am using cocos2d. I would like to be able to detect whether the screen is touched at a particular instant - that is, rather than intercepting an event when it occurs, I want to detect the presence of touch at a particular moment.
The reason is that I am animating sprites and want to determine if the sprite should keep moving - if the screen is still touched. I cannot use ccTouchesEnded because each time an animation starts I set isTouchEnabled to false because I also want the user to be able to tap rapidly on the screen to move the sprite but if they tapped too rapidly, it would mess with the position of the sprite during the animation process - which I have found screws up the positions of my objects in weird ways.
Is this possible?
There does not appear to be any public API to detect touches other than enabling and receiving these events in the main UI run loop.
You can keep handling events, and set the state left by the last touch event in a model object or global variables. Then you can poll your app's own internal state at any time.
Instead of disabling touches, you can just have your touch handler not do inappropriate things if the event time stamp is too close to some animation start time.

How can I check whether Exposé is being activated or not?

I'm creating an application that emulates MacBook's multi-touch Trackpad. As you may know, on MacBook's trackpad
if you swipe 4 fingers up, it triggers the Show Desktop.
if you swipe 4 fingers down, it shows the Exposé.
However, if the Show Desktop is being activated and you swipe 4 fingers down, it will come back to the normal mode. The same goes with the Exposé: if the Exposé is being activated and you swipe 4 fingers up, it will also come back to the normal mode.
Here is the problem: I use the keyboard shortcut F3 to show the Exposé and F11 to show the Show Desktop. The problem is, when the Show Desktop is being activated, if I press F3, it will go straight to the Exposé. And when the Exposé is being activated, if I press F11 it will go straight to the Show Desktop. But I want it to behave like Trackpad, which I guess its code may look like this
- FourFingersDidSwipeUp {
if (isExposeBeingActivated() || isShowDesktopBeingActivated()) {
pressKey("Esc");
} else {
pressKey("F11");
}
}
But I don't know how to implement the "isExposeBeingActivated()" and "isShowDesktopBeingActivated()" methods. I've tried creating a window and check whether its size has changed (on assumption that if the Expose is being activated, its size should be smaller), but the system always returns the same size. I tried monitoring the background processes during the Expose, but nothing happened. Does anyknow have any suggestions on this?
(I'm sorry if my English sounds weird.)
As far as I know, there's no public interface to any Exposé related functionality beyond the ability to specify the "collection behavior" of your own application's windows.
came here after reading your email. I understand the problem. After a bit of googling I found out what you already know, that there's really no official API or documentation for Exposé. A very ugly solution I've thought of could be having Exposé trigger a timer equal to the total time it takes to show all windows fully (guessing this is constant). If a swipe up would be done within that timer, it would mean that Exposé would still be active (isExposeBeingActivated()), so you would trigger a cancel instead of a Show Desktop. This wouldn't cover the use of the "slow motion" Exposé (via SHIFT key). Maybe you can detect if it's a normal or "slow motion" Exposé call?
Really sorry if this doesn't make sense at all within your application's scope, guess I'm just really saying the first solution I thought of.
Cheers.
Pedro.

iPhone SDK: Record time of buttons in a sequence to play back

I've got an app in development where you press a button to play a sound using System beep.
Instead of recording the output, I was thinking of recording the timing of when the buttons were pressed, so when the user presses a 'Play' button, the buttons are pressed in the same timing the user has pressed them, so it acts like the iPhone has recorded the sounds, but it's just playing them in sequence. I'd like this to occur once the user has pressed a Record button.
Example:
User presses record
Timing starts
records timing of each button pressed and when
Timing stops after a button has been pressed
PLay button plays back the sequence of events
Can anybody give any ideas on coding, documents to read etc.
Thanks a lot!
http://pastie.org/376474
This should hopefully help you out a bit.
It works in essence, though I haven't actually tested it, so I'm not positive it works.
I assume you can read through it and find a way to fit it in your own code.
Good luck!
Many system time methods have a way to get the value in seconds since the epoch.
Depending on the granularity of the system clock you can just grab the system time of the start button press and grab the time again when each button is pressed.
To calculate the timing just subtract the start time from the button press time.