gpt4 book ai didi

iphone - iOS 通知到达时推送特定 View

转载 作者:行者123 更新时间:2023-11-28 20:34:01 24 4
gpt4 key购买 nike

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
// Handle the notificaton when the app is running

NSLog(@"Recieved Notification %@",notif);

NSLog(@"local notifications count = %d", [[[UIApplication sharedApplication] scheduledLocalNotifications] count]);


CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"everything9", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);



[[NSNotificationCenter defaultCenter] postNotificationName:@"RELOAD_DATA"object:nil];

}

我可以在这里实现什么来在应用程序到达时推送特定 View (例如,当用户在 iPhone 锁定时滑动应用程序图标时)......我正在尝试 [self.navigationController pushViewController: CompletedViewController animated:YES]; 并且出现一些错误...我应该采用特定的方法吗?也许在 didFinishLaunchingWithOptions 中?

最佳答案

也许你应该这样称呼

[_window.rootViewController pushViewController:CompletedViewController animated:YES];

上面的代码现在不起作用。您应该尝试使用它。

 //We take the rootViewController first which is expected to be a UINavigationController in your case
UINavigationController *naviController = _window.rootViewController;
//We then call the push view controller code
[naviController pushViewController:CompletedViewController animated:YES];

如果您使用 Storyboard,这就是您从 AppDelegate 推送到当前导航 Controller 的方式。特别是当 Storyboard上的起点是导航 Controller 时。

关于iphone - iOS 通知到达时推送特定 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11203336/

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