Upravit

Sdílet prostřednictvím


UIApplication.ShortcutItems Property

Definition

Gets or sets the list of Quick Action shortcuts that the developer defined in code, as distinct from those defined in the Info.plist file.

[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual UIKit.UIApplicationShortcutItem[] ShortcutItems { [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)] [ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)] [Foundation.Export("shortcutItems", ObjCRuntime.ArgumentSemantic.Copy)] get; [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)] [ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)] [Foundation.Export("setShortcutItems:", ObjCRuntime.ArgumentSemantic.Copy)] set; }
member this.ShortcutItems : UIKit.UIApplicationShortcutItem[] with get, set

Property Value

The list of force touch Quick Action shortcuts that the developer has defined in code, as distinct from those that are defined in the Info.plist file.

This value can be null.

Attributes

Remarks

Application developers can define Quick Action shortcuts either in their application code (dynamically) or in the Info.plist file in the application bundle (statically). Statically defined Quick Action shortcut items are only available as an argument to the HandleShortcutItem method when the shortcut is selected by the user; they are not available in the ShortcutItems property. Only dynamically created shortcut items appear in ShortcutItems.

Statically defined shortcut items are preferentially displayed by iOS 9. That is, iOS displays as many statically defined shortcut as are allowed by the system first, and only then displays dynamically created quick action shortcuts up to the remainder of the system limit. The list of dynamically created shortcut items is displayed above the statically defined items, starting from the 0th position in ShortcutItems, and stacking successive entries above previous ones.

This list persists across application invocations.

The following example, when added to the Info.plist file, statically creates a force touch Quick Action shortcut:

<key>XSAppIconAssets</key>
<string>Resources/Images.xcassets/AppIcons.appiconset</string>
<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeSearch</string>
<key>UIApplicationShortcutItemSubtitle</key>
<string>Find something</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Search</string>
<key>UIApplicationShortcutItemType</key>
<string>PlistShortcut</string>
</dict>
</array>

The Quick Action shortcut defined above will not be available in ShortcutItems. If the developer places the code below into their FinishedLaunching(IUIApplicationDelegate, UIApplication, NSDictionary) method, then the dynamically defined shortcut item will be available after the first time the application is launched:

application.ShortcutItems = new UIMutableApplicationShortcutItem[] {
    new UIMutableApplicationShortcutItem ("DynamicItem", "Send") {
        LocalizedTitle = "Dynamic Item",
        LocalizedSubtitle = "Send Message",
        Icon = UIApplicationShortcutIcon.FromType
                    (UIApplicationShortcutIconType.Mail)
    }
};

Applies to