I have implemented an alternative keyboard on my first iPhone app. I would like to play a sound when a button is pressed. The default click sound when the standard keyboard is pressed would be fine, but I don't know how to get that sound.
In this answer I found how to play a 'tock' sound:
Playing system sound without importing your own
I got this to work easily enough but it is a very loud sound. I've searched Stack Overflow and the Xcode help for available iOS system sounds other than 'tock' and I can't find them.
Are there other built-in sounds, maybe even the default keyboard sound, that I can use?
Prior to, and since posting this question almost 2 weeks ago I have searched high and low for a method to make the keyboard click sound work in my app. I have attempted to implement and understand Apple's documentation on custom input views. I butchered my app in many ways attempting to make it work and created several test projects. I tried to interpret how to do this from various other sources on the web. All to no avail. I have finished my app all but for this last function.
I finally hit on a simple answer towards the end of this IPhone Dev SDK form question/post. The ultimate answer is easy and can be done in a few seconds with these easy steps.
Link the 'AudioToolbox.framework' to your project (Click on your project's Target, select 'Build Phases' and under the 'Link Binary with Libraries' item click the + button and add the framework.
Add the following to the header file of the class where you want to implement the click:
#import <AudioToolbox/AudioToolbox.h>
Add the following line of code in the implementation file of your class wherever you want the keyboard click sound to appear:
AudioServicesPlaySystemSound(0x450);
THAT'S IT! AND IT WORKED!!! HALLELUJAH!
According to Paul in the other forum this has the following downside:
"keyboard keys won't be affected by the iOS user preference for keyboard sound on/off."
But when I turn the volume up or down on my iPhone or if I mute the iPhone, the keyboard click sounds do go up and down or are muted as would be expected. Given that I found it impossible to implement keyboard clicks "UIInputViewAudioFeedback" as documented, I'm happy to have anything work.
P.S. If anyone has a link to an actual project that I can download, build and run on my iPhone to see EXACTLY how to properly implement: "UIInputViewAudioFeedback" I'd be happy to give it a look. But so far I've found none, nor any step-by-step newbie style instructions on how to make it work.
[Sept 30, 2012 UPDATE:] I'm happy to say that my app was accepted into the app store using this method. Here it is: https://itunes.apple.com/app/fine-tip-tip-calculator/id563429225
...Dale
Try UIDevice's playInputClick:
[[UIDevice currentDevice] playInputClick];
From the documentation:
Use this method to play the standard system keyboard click in response to a user tapping in a custom input or keyboard accessory view. A click plays only if the user has enabled keyboard clicks in Settings > Sounds, and only if the input view is itself enabled and visible.
Make sure you adopt the UIInputViewAudioFeedback protocol in your input view class, and implement the enableInputClicksWhenVisible delegate method to return YES, as per the documentation.
EDIT - For implementation of delegate methods, check out Apple's documentation on custom input views.
Related
I have implemented iOS rich notifications in my app based on Local and Remote Notification Programming Guide.
I watched WWDC Introduction to Notifications, Advanced Notifications, and Best Practices, and read UNNotificationContentExtension. All of these show that I can implement Notification Content extension to customize notification presentation. But to me it seems that they all assume that we can customize only the expanded view (the view that opens up when we 3D press the short preview).
Now I know that I can customize the presentation of the short preview in a very restricted way - using title/body I can decide if I want a bold or normal font; by using Notification Service extension I can add a media preview. However, what I need is to be able to build the UI of this short preview myself - add custom UIImageView, etc. Right now it seems that this is not possible, but I wasn't able to find any explicit information that would confirm it.
So my question is: Can we customize the short preview of a notification? If not, is there any explicit statement in official docs that explain this? If yes, can you refer me to some docs/tutorials on how to do it?
I just stumbled upon the following line in the Customizing the Appearance of Notifications article in the official documentation:
The system provides the interface for the abbreviated banner, but you can customize the full interface using a notification content app extension.
This confirms that currently there is no way of customizing the short preview ("abbreviated banner" in the docs).
I think (I'm not 100% sure) that you can only display an Attachment Image in the Notification banner, because you don't have Storyboad or UI file for this. It is the default Notification banner design.
You can follow this great guide (links below), it helps me understand Notification Content Extension and Notification Service Extension and all the logic behind and how it really works.
You can try to make some adjustments to the project, trying with anything else than ImageView, but as far as I know, the attachment is by default positioned at the right corner, as a miniature.
I am interested if you find additional informations.
Here is the great links that helped me build my Notification Feature in my App.
Sources:
Rich Notification Guide
Notification with Attachment
PS: I am also sad and disapointed that the expended view only appears with 3D Touch (People don't use it, 3D Touch is a failure to me).
I've been looking around on the internet and there doesn't seem to be much in the way of conversation (or I'm asking the wrong question - I'm new at Objective-C and iOS both) about creating a custom Assistive Touch-like button in iOS.
I would like to access my app from a launcher application and then float a button that would let me go back into said launcher from anywhere in my app. The floating Assistive Touch button scheme seems perfect - has anyone made something like that?
[EDIT]
In response to the meaningful questions - I wasn't clear enough (again, apologies - inexperienced here).
I have three apps: App Gatherer, App Target 01, App Target 02.
App Gatherer will be able to launch multiple apps via URL. Once it does that, and the new app opens, I'm wondering if I can have a floating button that can be moved around and clicked seperate from the UI of the Target App like the Assistive Touch button. The purpose of the floating button is to get me back out of any Target Apps - it's totally separate - to the Gatherer App.
I don't have any implementation - I'm just trying to map it out and see if it's even possible. Am I in the wrong place to ask that?
when u open a app using url from AppGatherer. Then in the Target app there is only 1 way of going back to appgatherer and that is using a url again but this time opening AppGatherer. So the custom floating button will have to be implemented inside the AppTarget and when the person clicks that button AppGatherer is opened via URL Scheme. There is no other way around. You cant have a floating universal button. You will have to implement the floating button inside every AppTarget application seperately. Plus it goes without saying that button will have to be implemented in every seperate view you have within the AppTargt application.
And in order to make a floating button you will need to keep above all other views plus handle its dragging within the onDrag methods and etc.
I am learning to develop iphone apps and I have a simple question.
I am making a really simple app which allows the user to set the volume of the device on the settings screen using a slider instead of the volume buttons.
It may be quite obvious for experienced developers but I just can't find the answer I am looking for.
My question is:
How can I make this slider?
Basically I want to do this (image: https://www.dropbox.com/s/b81bzdwyrab0ha7/slider.png?dl=0):
I used to think that I could use a regular UISlider but some documentation says that I need to use something called a MPVolumeView. The problem is that I can´t find a good tutorial that tells how to use this explicity.
I found this link on the apple documentation but I dont understand how this works. – http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPVolumeView_Class/Reference/Reference.html
And the description says: Use a volume view to present the user with a slider control for setting the system audio output volume, and a button for choosing the audio output route. When first displayed, the slider’s position reflects the current system audio output volume. As the user drags the slider, the changes update the volume. If the user presses the device volume buttons while sound is playing, the slider moves to reflect the new volume.
This is exactly what I want but I dont understand the example it gives. If you could please tell me how t make this slider work, even if it is on a new one-view project, I would really appreciate it.
Also I am aware that this method also creates an airPlay button next to the volume slider. Is there a way to delete this button? (My app is a simple productivity app so I only want the slider, not the airplay button).
I also understand that this will not work on the simulator. How am I supposed to know that this will work without having to test it on an actual device (I am not registered as a developer yet)?
Plus, I only know objective-c, not swift. If you could please restrain from using swift in your answers I would apreaciate.
Thank you so much for your help.
PD: English is not my first language. Sorry for any mistakes I made.
The MPVolumeView class is designed to let you do exactly this. It's in MediaPlayer.framework, so add that to your app to make things build correctly.
You create it and make it visible the way you instantiate any other subclass of UIView, which you probably know by now.
You disable the routing button by setting the "showsRoutingButton" property to false.
"How am I supposed to know that this will work without having to test it on an actual device?"
By seeing that it's been there since iOS 2.0, and is used in countless apps?
The process to writing such a slider is incredibly simple, look into UISlider(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISlider_Class/) and then use the float value from the slider to set the volume.
If you do not want to write your own slider, look on GitHub(github.com) for controls that do this for you. After doing a quick search, I found this UISlidersubclass that adjusts volume.
I am making demo videos of my iOS apps, some of which I made with XCode and others of which I made in Unity3D. I plan to use the Elgato Game Capture HD to capture my demo videos but I am not sure how to show the "taps." I found Touchpose, but when I changed the main.m as suggested by the instructions on the GitHub page I got error messages saying that QAppDelegate and QTouchposeApplication were undefined. I added import "QTouchposeApplication" but got an error message suggesting I change QAppDelegate to AppDelegate. When I did this the build failed. When I left it as QAppDelegate, added QAppDelegate to the project and imported it into the main.m the error messages went away but the build still failed. Am I doing something incorrectly? I found no tutorials on Touchpose online and am confused. Alternatively, is there some other easy solution, for example using the Elgato software or some other software or framework? I also tried Reflector but my wifi is not fast enough to support good frame rates with it. I am aware that I could use unity and "build for OSX" or in the case of XCode apps just screen record the simulator but I would prefer a single, foolproof solution for all of my apps. Thanks!
One way is to use assistive touch and create your own touch. You can do this by going to Settings > General > Accessibility > AssistiveTouch, turn it on, then tap the thing that pops up, click Custom, then create your own touch. Then use that touch to show taps in a screen recording.
It's a bad solution, but I'll post it in case it fits your needs.
You would have to superimpose multiple videos to make it so that only the tap shows and not the AssistiveTouch icon. Also, you can't scroll while using it.
It's also explained here: https://www.youtube.com/watch?v=4JqjU0-4Cek
Are you able to demo on a simulator? If so, Giphy Capture is a good solution. It has an option for showing taps in the settings.
If you can make your screen recording on iOS simulator, you can enable displaying taps with following code. Open your terminal and run it and restart your simulator.
defaults write com.apple.iphonesimulator ShowSingleTouches 1
I had trouble with Touchpose initially but figured out how to use it. The issue is that you have to go to build phases and add the .m. In regard to screen recording I am using the Elgato Game Capture HD. My only problem is showing the dots on Unity 3D applications, which is something I am still working on.
I'm currently using PhoneGap (Cordova) to build an App on iPad/iPhone.
One of my page in the app (in html/css/js), have more than 100 input type Number.
When i use finger to target each of them, it's working like a charm.
But when i use the prev/next button from IOS Keyboard, sometime, i don't know why, keyboard slide to down and when i try to open it again with targeting a input with my finger keyboard just blink... Impossible to fixe it without a scroll to release all event.
I've clean my code, refactored some part, look on google and stackoverflow if someone had the same problem but i found nothing...
Did someone know if it's a UIWebView problem ? Or phoneGap? or something else?
Thank's for reading.
If you are happy to just remove the next/previous buttons from your app entirely, the new Phonegap/Cordova 2.6.0rc1 has made this incredibly simple.
In your config.xml file, just set the HideKeyboardFormAccessoryBar preference to true.
In order for those two buttons to work you need to specify their behavior and it seems that it is not specified. Made some research and I think you have two options. Either you get rid of the next/previous buttons at all like explained here or you override textFieldShouldReturn: in a way similar to what is described in this post.