LoginSignup
4
5

More than 5 years have passed since last update.

3d touchのショートカット機能

Posted at

とりあえず3d touchを試すその3で
Home Screen Quick Actions
を試してみました。
参考のqiitaを見て守らればxmlで設定することはたぶんわかると思います。
UIMutableApplicationShortcutItem
の使い方はswiftの公式を見ながら適当に作り出しました。

AppDelegate.m
UIApplicationShortcutIcon *icon3 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeSearch]; // アイコンを作る xmlと同じ名前です。
    UIMutableApplicationShortcutItem *shortcut3 = [[UIMutableApplicationShortcutItem alloc] initWithType:@"aaa" localizedTitle:@"title" localizedSubtitle:@"subtitle" icon:icon3 userInfo:@{@"key": @"あああ"}];
code xml
initWithType UIApplicationShortcutItemType
localizedTitle UIApplicationShortcutItemTitle
localizedSubtitle UIApplicationShortcutItemSubtitle
icon UIApplicationShortcutItemIconType
userInfo UIApplicationShortcutItemUserInfo

って感じでコードでも
xmlでも設定するものは同じです。
サブタイトルいらない場合は
initWithType:localizedTitle:
UIApplicationShortcutIconにオリジナルを設定する方法までは調べてないです。
てかDropboxが既に実装されてますけど、これ遷移後の画面に飛ぶ場合はどうやってるんでしょうね。
公式のサンプルがしょぼいAlert出すだけだから感覚がつかめない。
DropboxはSearchAPIも対応してるし、すごいなーてか3d touchよりそっち調査したほうがよっぽど現実的だった。

こうやってるけど、やっぱり人の真似してるだけだなー 英語読んでない

サンプルコード

参考
3D Touch の Home Screen Quick Actions に対応する
iOS 9から追加された3D Touch shortcutsを実装してみる

リファレンス
UIMutableApplicationShortcutItem Class Reference

公式サンプル(Swift)
ApplicationShortcuts: Using UIApplicationShortcutItem

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5