vikeyToy 2012-10-29 09:27 采纳率: 0%
浏览 3785

UILocalNotification单击事件的问题

代码如下:

- (void) socketIO:(SocketIO *)socket didReceiveEvent:(SocketIOPacket *)packet
{
NSLog(@"didReceiveEvent(),%@",packet.data );



SysNotification *sysNotification=[GlobalVariable parseSysNotificationWithString:packet.data];


UILocalNotification *alarm = [[UILocalNotification alloc] init];
if (alarm) {
    alarm.fireDate = [NSDate date];
    alarm.timeZone = [NSTimeZone defaultTimeZone];
    alarm.repeatInterval = 0;
    alarm.soundName = UILocalNotificationDefaultSoundName;
    alarm.alertBody = @"Test message...";

    NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"];
    alarm.userInfo = infoDic;


    [[UIApplication sharedApplication] presentLocalNotificationNow:alarm];
}


}

我需要实现的是点击状态栏的UILocalNotification,出现一些视图控制器。怎么实现?

  • 写回答

1条回答 默认 最新

  • Mr_me 2012-10-29 09:45
    关注

    处理本地通知有两个情况:

    1,通过点击本地通知应用启动。

    -(BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        UILocalNotification *localNotif =
    
            [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    
        if (localNotif) {
    
           //load your controller
    
        }
    
        return YES;
    
    }
    

    2.应用是活动的,就把下面的代码加到AppDelegate中

       -(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
    
            //加载controller
    
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊