0
我在我的应用程序委托中添加了所有的3D触摸操作,但是如何更新整个应用程序中的其中一个操作的副标题?如何更新3D Touch快速操作本地化字幕?
我在我的应用程序委托中添加了所有的3D触摸操作,但是如何更新整个应用程序中的其中一个操作的副标题?如何更新3D Touch快速操作本地化字幕?
请看Apple的this reference。第一个代码示例为您提供了使用新的localizedTitle
修改现有快速操作所需的内容。
下面是Apple示例中的Objective-C代码。总之,您创建了一个UIMutableApplicationShortcutItem
,其中包含要修改的快捷方式项目的可变副本。更改标题,然后用新的替换上一个快捷方式。
NSArray <UIApplicationShortcutItem *> *existingShortcutItems = [[UIApplication sharedApplication] shortcutItems];
UIApplicationShortcutItem *anExistingShortcutItem = [existingShortcutItems objectAtIndex: anIndex];
NSMutableArray <UIApplicationShortcutItem *> *updatedShortcutItems = [existingShortcutItems mutableCopy];
UIMutableApplicationShortcutItem *aMutableShortcutItem = [anExistingShortcutItem mutableCopy];
[aMutableShortcutItem setLocalizedTitle: @“New Title”];
[updatedShortcutItems replaceObjectAtIndex: anIndex withObject: aMutableShortcutItem];
[[UIApplication sharedApplication] setShortcutItems: updatedShortcutItems];
虽然此链接可能回答问题,但最好在此处包含答案的基本部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/12131735) – frasertweedale
@frasertweedale我复制了Apple示例代码和一些说明文字。 – stevekohls
@stevekohls谢谢!得到它的工作! –