{"id":3776,"date":"2021-08-16T15:41:28","date_gmt":"2021-08-16T07:41:28","guid":{"rendered":"http:\/\/123.57.164.21\/?p=3776"},"modified":"2021-08-16T15:41:28","modified_gmt":"2021-08-16T07:41:28","slug":"apple-watch-digital-crown-tips","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=3776","title":{"rendered":"Apple Watch Digital Crown Tips"},"content":{"rendered":"\n<p>\u5b98\u7f51\u8bf4\u660e\uff1a<a href=\"https:\/\/developer.apple.com\/design\/human-interface-guidelines\/watchos\/interaction\/digital-crown\/\">https:\/\/developer.apple.com\/design\/human-interface-guidelines\/watchos\/interaction\/digital-crown\/<\/a><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-1024x707.png\" alt=\"\" class=\"wp-image-3777\" width=\"436\" height=\"300\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-1024x707.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-300x207.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-768x531.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-830x573.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-230x159.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46-350x242.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-46.png 1514w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><\/figure><\/div>\n\n\n\n<p>\u6709\u65f6\uff0c\u6211\u4eec\u5e0c\u671b\u4e8c\u6b21\u5f00\u53d1Digital Crown\uff0c\u6bd4\u5982\u70b9\u51fbDigital Crown\u65f6\uff0cApp\u54cd\u5e94\u4e00\u4e9b\u52a8\u4f5c\uff0c\u4f46\u662f\u4e0d\u5e78\u7684\u662f\uff0c\u8fd9\u4e2a\u624b\u52bf\u5df2\u7ecf\u662fIOS\u7cfb\u7edf\u5360\u7528\u7684\u624b\u52bf\u4e86\uff0c\u6ca1\u6cd5\u8fdb\u884c\u81ea\u5b9a\u4e49\u5f00\u53d1\u3002\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u6355\u6349\u5230Digital Crown\u65cb\u8f6c\u7684\u6570\u503c\uff0c\u4ece\u800c\u505a\u4e00\u4e9b\u4e8b\u60c5\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u5177\u4f53\u7684Demo\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/dev.to\/no2s14\/how-to-use-wkcrowndelegate-in-watchos-development-1lj9\">https:\/\/dev.to\/no2s14\/how-to-use-wkcrowndelegate-in-watchos-development-1lj9<\/a><\/p>\n\n\n\n<ul><li><strong>UIkit\u7684\u60c5\u51b5<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import WatchKit\nimport Foundation\n\nclass InterfaceController: WKInterfaceController {\n\n    override func awake(withContext context: Any?) {\n        \/\/ Configure interface objects here.\n    }\n\n    override func willActivate() {\n        \/\/ This method is called when watch view controller is about to be visible to user\n    }\n\n    override func didAppear() {\n        super.didAppear()\n        crownSequencer.delegate = self\n        crownSequencer.focus()\n    }\n\n    override func didDeactivate() {\n        \/\/ This method is called when watch view controller is no longer visible\n    }\n\n}\n\nextension InterfaceController : WKCrownDelegate {\n    func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {\n        print(rotationalDelta)\n    }\n}\n<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-1024x696.png\" alt=\"\" class=\"wp-image-3778\" width=\"529\" height=\"359\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-1024x696.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-300x204.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-768x522.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-830x564.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-230x156.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-350x238.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47-480x326.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-47.png 1310w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/figure><\/div>\n\n\n\n<ul><li>SwiftUI\u7684\u60c5\u51b5<\/li><\/ul>\n\n\n\n<p>SwiftUI\u5b9e\u73b0\u8d77\u6765\u5c31\u6bd4\u8f83\u7b80\u5355\u4e86<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\nimport SwiftUI\n\nstruct ContentView: View {\n\n    @State var rotationValue = 0.0\n\n    var body: some View {\n        VStack {\n\n            Text((\"\\(self.rotationValue)\"))\n                .padding()\n                 \/\/ \u8fd9\u91cc\u628a\u8868\u51a0\u65cb\u8f6c\u7684\u6570\u503c\u7ed1\u5b9a\u5230rotationValue\n                .focusable(true)\n                \/\/ \u8fd9\u91cc\u628a\u8868\u51a0\u65cb\u8f6c\u7684\u6570\u503c\u7ed1\u5b9a\u5230rotationValue\n                .digitalCrownRotation($rotationValue)\n                \/\/ \u8fd9\u91cc\u76d1\u542c\u5230rotationValue\u7684\u53d8\u5316\uff0c\u53ef\u4ee5\u505a\u4e00\u4e9b\u4e8b\u60c5\n                .onChange(of: rotationValue) {\n                    value in\n                \/\/ \u6253\u5370rotationValue\u7684\u503c\n                print(value)\n\n            }\n\n        }\n\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-48.png\" alt=\"\" class=\"wp-image-3780\" width=\"253\" height=\"276\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-48.png 346w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-48-275x300.png 275w, https:\/\/92it.top\/wp-content\/uploads\/2021\/08\/\u56fe\u7247-48-230x251.png 230w\" sizes=\"(max-width: 253px) 100vw, 253px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u7f51\u8bf4\u660e\uff1ahttps:\/\/developer.apple.com\/design\/human-interface [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3776"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3776"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3776\/revisions"}],"predecessor-version":[{"id":3781,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3776\/revisions\/3781"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}