gpt4 book ai didi

ios - 3D 触摸主屏幕操作,Launchoptions 始终为零,即使从

转载 作者:行者123 更新时间:2023-11-29 01:16:25 33 4
gpt4 key购买 nike

启动选项始终为零。

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Launch options is always coming nil
//even when I launch from 3D touch shortcut icon
shortcutItemkey = [launchOptions objectForKey:UIApplicationLaunchOptionsShortcutItemKey];

return N0;
}

performActionForShortcutItem 委托(delegate)方法照常被调用。

-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler {

completionHandler([self handleShortcut:shortcutItem]);

}

最佳答案

- (void)shortcutsWithIcon
{
@try
{
UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"img_editProduct"];
UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"img_Classifieds"];

UIMutableApplicationShortcutItem *item1 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.3dtouchApp.postAnItem" localizedTitle:@"Post an Item" localizedSubtitle:@"Add new product for sale" icon:icon1 userInfo:nil];
UIMutableApplicationShortcutItem *item2 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.3dtouchApp.LatestAds" localizedTitle:@"Latest Ads" localizedSubtitle:@"View top recent Ads" icon:icon2 userInfo:nil];
NSArray *items = @[item2, item1];

[UIApplication sharedApplication].shortcutItems = items;
}
@catch (NSException *exception) {

}
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (self.window.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
{
[self shortcutsWithIcon];
UIApplicationShortcutItem *item = [launchOptions valueForKey:UIApplicationLaunchOptionsShortcutItemKey];
if (item) {
NSLog(@"We've launched from shortcut item: %@", item.localizedTitle);
} else {
NSLog(@"We've launched properly.");
}
if ([item.type isEqualToString:@"com.3dtouchApp.postAnItem"])
{
***//Code for launch your screen***
}

if ([item.type isEqualToString:@"com.3dtouchApp.LatestAds"])
{
***//code for launch your screen***
}
}
return YES;
}
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
if ([shortcutItem.type isEqualToString:@"com.3dtouchApp.LatestAds"])
{
***//Code for launch your screen***
}
if ([shortcutItem.type isEqualToString:@"com.3dtouchApp.postAnItem"])
{
***//Code for launch your screen***
}

}

关于ios - 3D 触摸主屏幕操作,Launchoptions 始终为零,即使从,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35124210/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com