This bug has been PARTIALLY fixed in iOS 8.x! for iOS 8.x you only need a timeout value of 0. For older OSes, you will need larger timeout values.
This page demonstrates how effed up focus management is in iOS 7.x with Voiceover. The focus is supposed to end up on the "No Thanks" button. Instead, depending on the value of the timeout for the second setTimeout call, it will end up somewhere between the top of the document and the button intended. To get it to reliably not set focus anywhere near the intended button, simply call "focusButton(3)" immediately after "focusDialog(3)" or even instead of it. To get it to reliably set focus to the intended button, first focus something else i.e. call "focusDialog(3)" and then wait 1 second and then call "focusButton(3)".
The fact that it is not possible to tell when VoiceOver is running means that you have to mess up the user experience of all your other users too in order to get this sort of behavior to function correctly on iOS devices for VoiceOver users.