現在、私のアプリはすべて Obj-C で書かれています。3D Touchでホーム画面ショートカットを実装するサンプルコードのリンクhttps://developer.apple.com/library/content/samplecode/ApplicationShortcuts/Introduction/Intro.html#//apple_ref/doc/uid/TP40016545が完全にコンパイルされていますスイフトで。Obj-C のドキュメントに出くわした人がいるので、AppDelegate を調べてすべてを翻訳する必要はありませんか?
アップデート:
Info.plist にすべてのショートカットを追加した後、AppDelegate.m に追加しました。
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
UINavigationController *nav = (UINavigationController *) self.tabBarController.selectedViewController;
NSLog(@"%@", shortcutItem.type);
if ([shortcutItem.type isEqualToString:@"com.316apps.iPrayed.addPrayerRequest"]) {
Requests *gonow = [[Requests alloc] init];
[nav pushViewController:gonow animated:YES];
}
if ([shortcutItem.type isEqualToString:@"com.316apps.iPrayed.addPrayer"]) {
PrayerStats *controller = [[PrayerStats alloc] init];
[nav pushViewController:controller animated:YES];
}
if ([shortcutItem.type isEqualToString:@"com.316apps.iPrayed.addFast"]) {
FastStats *controller1 = [[FastStats alloc] init];
[nav pushViewController:controller1 animated:YES];
}
if ([shortcutItem.type isEqualToString:@"com.316apps.iPrayed.addStudy"]) {
StudyStats *controller2 = [[StudyStats alloc] init];
[nav pushViewController:controller2 animated:YES];
}
}
これにより、他のメソッドを入れたり、didFinishLaunchingWithOptions に何かを追加したりしなくても、機能することができます。