How to add a label in a settings screen - iphone

As a picture says more than a thousand words:
alt text http://img.skitch.com/20091008-k16k7we3t43gj3h7htgtjpunpx.jpg
Any help on how to add descriptive labels to a settings pane would be highly appreciated!
I should point out that I want to do this to be in the iPhone-App settings that are in the Settings menu of the iPhone (outside the App).
Example label:
iPhone -> Settings -> Safari -> Fraud Warning
The label beneath: "Warn when visiting fraudulent websites."

For reference: Since iOS4.0 and above a FooterText key was added to PSGroupSpecifier that does exactly what you are looking for.
http://developer.apple.com/library/ios/documentation/PreferenceSettings/Conceptual/SettingsApplicationSchemaReference/SettingsApplicationSchemaReference.pdf (pg 11)

Unfortunately, Apple has not given iPhone developers the capability to add the kind of label you're looking for in Settings.app. As a near approximation, I've used PSGroupSpecifier under another setting element (such as PSToggleSwitchSpecifier). It's not as elegant as a true label, but it worked well enough in my situation (I only had one setting, so it didn't conflict with any other group headings).
alt text http://pseudorandomengineer.com/images/6.png

Try using a PSTitleValueSpecifier in your settings bundle's plist. I'm not sure how that formats itself—most likely bold, like the group headers—but it might be what you're looking for.

If you want to simulate a label that is center-justified, add an empty title PSGroupSpecifier and put your label text in the FooterText Key.

Check out the tableView:titleForFooterInSection: method of UITableViewDataSource. You can return a string to be displayed below a table view section. If you're already using a UITableViewController subclass, just implement that method and you're good to go.

Related

Swift - disable accessibility voiceover?

I was curious if there was a way to disable the voiceover accessibility (or any other type of accessibility feature for that matter - like hear aids, captioning, etc.) in swift?
Essentially, I'm trying to build an application that has a very high likelihood of being used by people with visual impairments and I've tailored my entire application for such people.
But given that this target group may have the voiceover accessibility feature on, can I disable that only within my application?
I see that on xcode 7, underneath the identity inspector, there is a section for accessibility (picture below) and I tried unchecking that box but it seems like voiceover and the highlighting focus feature are still in effect. Let me know if you have any suggestions or comments, thanks.
You can set
element.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction
on any elements that you want to provide custom audio/interactions for.
This can also be accomplished in storyboard (See photo).
I came across this thread because I was trying to do this for on a game scene tucked inside of a view container. To get it to work, I was able to set
.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction
on each SKNode that had custom accessibility created for it, and then was able to select the proper options (again see screenshot) on the SKView -> View in Storyboard to allow the game screen to work.

Is there an existing iOS component to type in a UITextView? [duplicate]

In my app I want the user to type names into a UITextField (or equivalent) and then when they press return, it will put that word(s) in a blue bubble that's usually associated with tags. The cursor then moves to the end where they can add more "tags".
This can be seen when adding contacts in the To, CC & BCC fields in the Mail app, and also when selecting contacts in the Messages app.
How is this done? Is it something that's provided in the UIKit or available somewhere else?
Many thanks,
Michael
Venmo just open sourced their token field.
https://github.com/venmo/VENTokenField.git
edited:
The equivalent control in desktop Cocoa is an NSTokenField, but there doesn't seem to be an equivalent for Cocoa Touch.
Since iOS 13 there exists UISearchTextField.
https://developer.apple.com/documentation/uikit/uisearchtextfield
You can see that component in action in the Photos App.
That should fit for many use cases. By removing the leftView you can also get rid of the search icon.
But be aware: You can‘t mix text and tokens at various positions.
From the docs:
Tokens always occur contiguously before any text in the search field.
Adding this here for reference:
Feel free to check out TaggerKit (a library I made), it's more or less what OP was talking about. You can basically add tags functionality to your app by just adding a view and a couple of properties.
I dont think you can do it with any built in functionality in the SDK, never seen such a feature. What you could do however is implement it yourself, have some custom blue button with some text over it, and when the user hits return you can have some code that takes the text and returns you the button that you need, shouldnt be too bad to implement

Iphone SDK, switch keyboard in app

I have one question, may be it is very simple, but I do not know about this nothing...
For example, I have an application, application with textfield, I want to know two things.
First: Is possible to switch keyboard when application in runtime?
Second: how I can switch type of keyboard(Russian, English, Swedish, etc.) in my application*?
*-without going to Settings->General->Keyboard->add new keyboard.
Not sure about changing languages (I did find this other post about it: change input source language programmatically OSx), but changing the keyboard is pretty easy. Here is a one line example:
textField.keyboardType = UIKeyboardTypeURL;
Take a look at the UITextInputTraits protocol reference for more info. Then the question comes in where to implement this. I am assuming that you want to check conditions right before the keyboard comes up, you may have to implement UITextFieldDelegate protocol (and maybe using the field's tag to see which field the cursor is in).
Hope this helps.

Can I subclass UIMenuController so that it can take icons instead of just text?

How would one go about doing this? I'm looking for a dense, purely graphical menu on tap-hold.
In 3.2 you can add menu items using the menuItems property. But I think subclassing won't be useful, since it's a singleton that does not returns the views of each menu item. You could access menuFrame when setMenuVisible:animated: is called, so you can add you're own view that looks like a menu items with icons. But for adding icons to the system menu items... I think you should stick to what's Apple is giving you ;)
My low reputation don't let me post links, therefore I am answering again here:
Check Emoji & Symbols, perhaps it will fit to your purpose.
Go to your Xcode Menu -> Edit -> Emoji & Symbols.
Ex.:
let menuItemYes = UIMenuItem(title: "✅", action: "doSomething")
Good luck!
I wrote a category to support image for UIMenuItem. It's based on method swizzling, but should be safe in most cases.
https://github.com/cxa/CXAImageMenuItem
Note: duplicate answer to https://stackoverflow.com/a/14140904/395213
EDIT: the above link is 404'ed, this link works
https://github.com/cxa/UIMenuItem-CXAImageSupport

Is there an iPhone equivalent to the NSTokenField control?

In my app I want the user to type names into a UITextField (or equivalent) and then when they press return, it will put that word(s) in a blue bubble that's usually associated with tags. The cursor then moves to the end where they can add more "tags".
This can be seen when adding contacts in the To, CC & BCC fields in the Mail app, and also when selecting contacts in the Messages app.
How is this done? Is it something that's provided in the UIKit or available somewhere else?
Many thanks,
Michael
Venmo just open sourced their token field.
https://github.com/venmo/VENTokenField.git
edited:
The equivalent control in desktop Cocoa is an NSTokenField, but there doesn't seem to be an equivalent for Cocoa Touch.
Since iOS 13 there exists UISearchTextField.
https://developer.apple.com/documentation/uikit/uisearchtextfield
You can see that component in action in the Photos App.
That should fit for many use cases. By removing the leftView you can also get rid of the search icon.
But be aware: You can‘t mix text and tokens at various positions.
From the docs:
Tokens always occur contiguously before any text in the search field.
Adding this here for reference:
Feel free to check out TaggerKit (a library I made), it's more or less what OP was talking about. You can basically add tags functionality to your app by just adding a view and a couple of properties.
I dont think you can do it with any built in functionality in the SDK, never seen such a feature. What you could do however is implement it yourself, have some custom blue button with some text over it, and when the user hits return you can have some code that takes the text and returns you the button that you need, shouldnt be too bad to implement