Swift - disable accessibility voiceover? - swift

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.

Related

How to programmatically present the WebKit inspector for a WKWebView?

Is there a way to programmatically present the WebKit inspector for a WKWebView? I am aware of how to enable the inspector for a WKWebView but what I would like to do is, similar to what is described here for a WebView, to be able to also directly pop it up on the screen programmatically from my own code. Use of private APIs and other hacks are naturally OK for me to accomplish, as this is only for debugging purposes.
The use case I have for this in my debugging flow is a WKWebView in my desktop based app where the right-click events that would usually allow for a context menu to be used for something else app specific.
As a workaround, would be happy with any means not involving right-clicking in the web view itself to bring up the inspector.
Reclaiming the right-click, eh? Interesting.
I had to plumb a large portion of WKWebKit2 C API headers into my swift app's build.
Roughly, to pull up the JS console:
WKInspectorShowConsole(WKPageGetInspector((wkwebview.subviews.first as! WKView).pageRef))
The gory details:
https://github.com/kfix/MacPin/commit/5fed6cb01ab88170f1387122748f8c4ae9e2cab5#diff-c5ffd49d5bf2cde5e056621f9ab14545R426
You need to pull in WKBase.h and WKView+Privates.h

Implement swipe gestures in apple watch using watchOS2.0

Hi I need to implement a functionality in my apple watch where when user swipes down will move from one module(InterfaceController1) to another module(InterfaceController2).And when user force touch menu should pop up and tapping on any button in the menu should present a model.
I am able to implement forceTouch menu option. But where as with swipe down to move to second module, i am not able to get any doc about this.
Please let me know if someone is aware of it.
Short Answer:
No, You can't.
Long Answer:
All WKInterface objects are proxy objects(aka Remote UI) that allows you to send queries to real UI Objects.
Reminds that the bundle that contains storyboard is separated with extension bundle. In sand-box concept, Your code that running on extension bundle can't access real UI Objects directly.
So there is no way to react against of user actions except that are available with interface builder(aka sentAction).

need consulting for a gui with 5 settings to be chosen by the user

I would like to let the user set 5 different settings. Each setting has a finite amount of values to choose (in my case : smaller, small, normal, large, very large)
I tried to use the UIPickerviews for this, but it needs a lot of space and I would like to have all on one page. I realized, that apple doesn't support simple dropdowns in IOS!?!?
following sample just shows only one setting and it fills up 1/3 of the screen.
In Android I managed to do this with simple dropdowns.
Any hints on how I could do this, without programming my own dropdown box ?
iOS does not have dropdowns as you say. I have created a custom control for my company that implements a dropdown. Some of my fellow iOS developers have yelled at me and said the dropdowns don't follow Apple's HIG. (You can take a look at our free app FaceDancer to see our dropdown control if you're interested.)
Apple uses picker views instead. What you can do is to have some sort of clickable element for each item (buttons for each one, e.g. "pick size", or make each field itself clickable) that displays a picker on top of the screen to let the user pick that value.
Note that there are large numbers of (both free and paid) third party frameworks offering all kinds of additional controls. I bet somebody has implemented a drop-in dropdown menu for iOS. Take a look at CocoaControls and search the iOS section for "dropdown". You can also look on Github and SourceForge.net.
I solved my problem by using a UISegmentedControl.
In my case with only 5 values, for me its the best choise. But for more then 10 values we have to use obviously external controls as Duncan mentoined.
var arraySizes5 = [sverysmall, ssmall, snormal, slarge, sverylarge];
var segmentcontrol_TextSizeTextViewer = UISegmentedControl();
segmentcontrol_TextSizeTextViewer = UISegmentedControl(items: arraySizes5);
self.view.addSubview(segmentcontrol_TextSizeTextViewer);

iPhone dev: Creating sliding drawers like Path and Facebook apps

The new Facebook app seem to have done away with the grid-icon layout, with a more interesting custom navigation layout where the bottom-most view shows all the options (like Profile, News Feed, Messages etc for Facebook) and clicking on one of them brings another view sliding over the top. You can press the 3-lines button to then expose the bottom-view again, but the current view is partially visible. The Path app also recently updated to match this scheme.
What's the best way to recreate this? I've searched for any open-source options but haven't found them. Three20 doesn't seem to support this either.
Another option that I wrote: ECSlidingViewController
It has support for orientation changes like Facebook and sliding to the left like Path.
Video demo: http://vimeo.com/35959384
Code: https://github.com/edgecase/ECSlidingViewController
Try These from Cocoa Controls:
JTRevealSidebar http://cocoacontrols.com/platforms/ios/controls/jtrevealsidebar
clcascade http://cocoacontrols.com/platforms/ios/controls/clcascade
StackScrollView http://cocoacontrols.com/platforms/ios/controls/stackscrollview
Many more on the same site like:
http://cocoacontrols.com/platforms/ios/controls/mfslidingnavigationcontroller
http://cocoacontrols.com/platforms/ios/controls/psstackedview
I found a really nice project on github:
https://github.com/devindoty/DDMenuController
Everything I've seen on the internet and those recommended by Yosi Taguri are all way too complicated. Drawers can be achieved by a very simple category to UINavigationController with no graphics asset whatsoever and no class extension needed, and backwards compatible with iOS 3.0!
Take a look a this:
http://code.google.com/p/drawer-navigation-controller/
Here is a video http://www.youtube.com/watch?v=5T-1-_pFbG0
This project (not mentioned above) looks like the most mature and polished to me: https://github.com/gotosleep/JASidePanels
Also, seems to still be active.
Edit: I have since transitioned to: https://github.com/mutualmobile/MMDrawerController which IMO is an almost perfect implementation.
Check my answer here - SplitView like Facebook app on iPhone - which contains a list of open-source codes.
if anyone's wondering which one to choose among JTReveal and DDMenu, I'd suggest DDMenucontroller over JTRevealSidebar (haven't used the other options listed by #Yosi). Its a lot simpler, lighter and works exactly the way the Path app works (and it is easier to modify to suit your requirements). Havent seen the issue of black background mentioned by #Henning
My project FRLayeredNavigationController on GitHub goes in about the same direction.
(The spacing between the layers is easily configurable and it supports rotation of course).
Have a look at the demo videos/screenshots:
http://youtu.be/v_tXD_mL05E
http://youtu.be/q66HX2td_uc
https://github.com/weissi/FRLayeredNavigationController/raw/master/FRLayeredNavigationControllerScreenshot1.png
https://github.com/weissi/FRLayeredNavigationController/raw/master/FRLayeredNavigationControllerScreenshot2.png
Here's another one: PPSlideDrawer.
http://www.localwisdom.com/blog/2013/05/simple-sliding-drawer-implementation-for-ios/
I checked out #Ephraim's answer (http://code.google.com/p/drawer-navigation-controller/) because it seems pretty easy to work with. The problem, it seems, with drawer-navigation-controller is that the swiping animation does not follow the user's finger--it is automated. PPSlideDrawer aims to solve that. I'm about to try it out in my project and will post some updates.
Might be a dealbreaker for some that the following are still under "TODO:"
Implement auto open functionality.
Implement swipe from edge functionality(rather than just detect panning gesture).
Landscape support.
Here is one thats very easy to implement and use with storyboards. It has control for shrinking, show hide animations, and direction.
https://github.com/HelloMihai/HMSideDrawerDirectional

How to add a label in a settings screen

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.