So I want a pretty basic 3D touch setup. On my main UI, I have a 2 option segmented control and I basically want to have one option of it selected upon open when 3DQuickActionA is used, and the other option when 3DTouchQuickActionB is used.
I've looked at other questions on this site, and one suggested I use:
- (void)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem {
if([shortcutItem.type isEqualToString:@"3DQuickActionA"]){
self.quote_opt.selectedSegmentIndex = 0; }
if([shortcutItem.type isEqualToString:@"3DQuickActionB"]){
self.quote_opt.selectedSegmentIndex = 1; }
}
where quote_opt is the name of my segmented control.
However, this doesn't work. My app launches ok, but just has whatever the last value of quote_opt was as the current option-- the 3D touch actions do nothing. I'm sure I'm missing something, but I don't know what. Does something need to go in viewdidload?
Any advice would be appreciated, and I'm happy to post whatever other portions of code/answer any other questions needed to solve the problem.
Thank you!
You also need to check the launchOptions
in didFinishLaunchingWithOptions
.
So, as the result of the ongoing chat, here's the latest code:
AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
if(launchOptions)
{
UIApplicationShortcutItem *selectedItem = [launchOptions objectForKey:UIApplicationLaunchOptionsShortcutItemKey];
if(selectedItem)
{
[self applyShortcutItem:selectedItem];
}
}
return YES;
}
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
[self applyShortcutItem:shortcutItem];
}
- (void)applyShortcutItem:(UIApplicationShortcutItem *)shortcutItem
{
ViewController *rootViewController = (ViewController *)[self.window rootViewController];
if([shortcutItem.type isEqualToString:@"DogModeShortcut"])
{
[rootViewController setShortcutAction:LaunchDogMode];
}
else if([shortcutItem.type isEqualToString:@"CatModeShortcut"])
{
[rootViewController setShortcutAction:LaunchCatMode];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With