in the native apps, digital crown can control lists, pickers and volume
in WatchOS 2, WKInterfacePicker
can be used accompanying with digital crown. There are 3 styles :
list style:
Stack style:
Sequence style:
we can also put the text on the top of the focused UI
The scroll indicator can be hidden if the context is not fit
Use Coordinating images for any interesting UI via digital crown
use picker.setItems([WKPickerItem])
to set items in the picker
use IBAction func pickerAction(selectedIndex: Int)
for getting selected index
layout the UI as follows :
and config with :
let progressImages = UIImage.animatedImageWithImages( [WKImage], duration: 0.0)
// WKImage can be initialized with local asset, remote with imageData: or draw with Core Image
progressInterfaceGroup.setBackgroundImage(progressImages)
picker.setCoordinatedAnimations( [progressInterfaceGroup, ...])
once it set up , picker will assign the background image according to current selected index.
make sure picker item generates very fast as the list can scroll though many items in a short time.
WKMediaPlayerControllerOptionsAutoplayKey:
, WKMediaPlayerControllerOptionsStartTimeKey:
,WKMediaPlayerControllerOptionsVideoGravityKey:
(aspect ratio)WKInterfaceMovie
is also provided if the player required to embed in other controllers. Movie remote url, the poster(the thumnnail image to preview) and the video gravity ( the aspect ratio)
func setupMovie() {
//movie pointer set up via storyboard
movie.setMovieURL(url)
movie.setVideoGravity(.ResizeAspectFill)
movie.setPosterImage(poster)
}
Sharing Data with the containing app
call the following to get recording
presentAudioRecordingControllerWithOutputURL(url, preset: .NarrowBandSpeech, maximumDuration:60.0 , actionTitle:"Send") { didSave, error in
// ...
}
and different preset for different bitrates
Store the data securely with locks/unlock mode
No iCloud Keychain
let secret = "somethingSecert"
if let secret = secret.dataUsingEncoding(NSUnicodeStringEncoding) {
let attributes: [NString: NSObject] = [
kSecClass: kSecClassGenericPassword,
kSecAttraccessible: kSecAttrAccessibleWhenUnlocked,
kSecAttrSErvice: "myService",
kSecAttrAccount:"account name",
kSecValueData : secretData
]
SecItemAdd(attributes, nil)
}