I'm trying to detect if an iPhone was moved (even a slight movement), and then if the device was moved, i want the iPhone to play a sound.
Im new to IOS programming, and I've looked through a bunch of apple documentations, and i found that i must use CoreMotion . But I'm not sure how to implement it, to what id like to do in my app.
I've also searched on google for some help (e.g. NSHipster...), but i couldn't fine anything that meets my needs.
can anyone assist?
Thank you.
It seems that you need the motion accelerometer in CMMotionManager.
https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMMotionManager_Class/index.html#//apple_ref/occ/instm/CMMotionManager/accelerometerData
It seems you want to detect an iPhone shake. Apple has an article on the subject:
https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html#//apple_ref/doc/uid/TP40009541-CH6-SW2
Related
I'm playing around with the audio features in iOS, and I'm looking at MPRemoteCommandCenter's changePlaybackRateCommand. I have enabled it, given it a target, and set its supportedPlaybackRates, but I don't see any related UI showing up in control center or the lock screen. And other commands I've set up, like skip forward, skip back, like, dislike, and bookmark, show up properly.
How does a user trigger a MPChangePlaybackRateCommand on iOS?
I face this problem and when I search I get other people face the same problem here
but I found something strange when I play podcast app in apple watch I found rate icon and I change the playrate from it
I think it's not work in iPhone (iPhone 6 iOS 11 ) but appear and work in another Apple devices in my case Apple watch
in iOS example here Apple not add MPChangePlaybackRateCommand like other commands that make me sure about it's bug in iOS
Can you suggest any idea to prevent screen recording as user make copy of my content by screen recording.
Thank you!
The UIScreen.isCaptured property is the recommended way of doing this by Apple. See the following article:
https://developer.apple.com/library/content/qa/qa1970/_index.html#//apple_ref/doc/uid/DTS40017687
I don't think so Its possible because still apple officially does not announce that we can do like that but as I know that in iOS 11 UIScreen has new property isCaptured
True if this screen is being captured.
You can do something by use of it. But not sure that you can prevent screen recording.
Second below question might be helpful for you.
Prevent screen capture in an iOS app
How can I manually trigger a single click-like vibration like the ones that happen when using peek&pop, or application shortcuts?
This method is easy to implement and it works really well (I tried it myself)
import AudioToolbox
AudioServicesPlaySystemSound(1519) // Peek feedback
AudioServicesPlaySystemSound(1520) // Pop feedback
AudioServicesPlaySystemSound(1521) // Three pulses feedback
I hope this helps! :)
It seems that these guys have found a way to do it for iOS 9 for phones with Taptic Engine (including the iPhone 6S). http://unifiedsense.com/development/using-taptic-engine-on-ios.html I'm not sure if it applies to iOS 8 or any other phones. They've essentially retrieved the Taptic Engine interface from UIDevice and called actuateFeedback with an integer corresponding to Peek or Pop.
Unfortunately these apps would likely be rejected by the App Store, if that's your intention.
I am developing application to get threshold how forcefully user shook iOS device. I am using iOS sdk 6.0.
I tried UIResponder delegate method motionEnded:: It get called when device is shaken but do not give enough data that how forcefully some one shook device.
I searched enough and found a single solution to use UIAccelerometer didAccelerate call back method. But it is not getting called. Is it sdk issue? As this method is deprecated in iOS 5.
I also tried coreMotion framework but that gives gyroscope data that how much device have been rotated but not how much it is has been shaken.
What is the best way of doing this.
I followed How do I detect when someone shakes an iPhone? but found no useful answer.
I just figured it out. iOS simulator do not respond to UIAccelerometer actions even if you perform shake gesture or rotate the simulator. It will not work. But if you run on device you will find same piece of code is running fine :)
Try this, in your view did load just do this:
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
This made it work for me. Dont need to use the variable at all, but it has something to do with setting the shared accelerometers delegate to self
can you trigger airplay mirroring with iOS 5 code?
I see in the API how you can stream. Just wonder if anyone knows how to turn on and off mirroring programmically in my app on iPad2 using iOS5, or if that even is possible.
I DO see how to physically turn it on via the dock at the bottom of the screen,
so no need to post a link to the Apple demo of that.
Thanks in advance
It's currently not possible. With a bit of luck this may change tomorrow, but it isn't something I can see apple doing. (for the same reasons as they dont allow toggling bluetooth/airplane mode/wifi etc..)