0
- (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];

}

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

4

5 回答 5

3

也许你应该称之为

[_window.rootViewController pushViewController:CompletedViewController 动画: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];

如果您使用情节提要,这就是您从 AppDelegate 推送到当前导航控制器的方式。特别是如果您在故事板上的起点是导航控制器。

于 2012-06-29T10:37:28.903 回答
0

“[self.navigationController pushViewController:viewController Animation:YES];”

这不能在 AppDelegate.m 中使用(即来自 didReceiveLocalNotification)。

使用 didReceiveLocalNotification 中的“self.pushViewController”尝试一次。

于 2012-06-26T11:35:13.907 回答
0

我认为将满足您的需求。它将教如何使用UINavigationController里面的AppDelegate. 如果您还有其他问题,请告诉我。

于 2012-06-26T08:39:36.407 回答
0
if ([EntNotStrApp isEqualToString:@"1"])
{
    EntNotStrApp=@"0";

    UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];

    UINavigationController *navController = (UINavigationController *)window.rootViewController;

    DumpFeed *dump = [storyboard instantiateViewControllerWithIdentifier:@"DumpFeed"];

    dump.isPushed=YES;

    dump.strUserId = appDelegate.strFriendid;


    [navController pushViewController:dump animated:YES];

}else
{
     [[iToast makeText:NotMess] show];
}
于 2015-02-03T06:26:50.910 回答
0

在旧版本的 Xcode 中,我们在创建应用程序时有一个选项是基于导航的应用程序。但是在最新一代的 Xcode 中,我们可以创建基于单视图或基于窗口的应用程序。所以,如果你想使用导航控制器的属性,你需要为 UINavigationController 创建实例并且需要设置 rootViewController。代码如下,

appDelegate.h

@property (strong, nonatomic) UINavigationController *navigationController;

appDelegate.m

@implementation AppDelegate
@synthesize navigationController = _navigationController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}

这样,您就可以在整个应用程序中使用导航属性。

我认为这可能对你有帮助。

于 2012-06-26T08:53:34.747 回答