【问题标题】:I Need To Stop OR Cancel UILocalNotification我需要停止或取消 UILocalNotification
【发布时间】:2011-09-08 00:33:03
【问题描述】:

我需要按功能取消 UILocalNotification 但如果我使用

[[UIApplication sharedApplication] cancelAllLocalNotifications];

我再次进入应用程序,但应用程序卡住了,这是计时器

UILocalNotification *local = [[UILocalNotification alloc] init];
    local.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
    local.timeZone = [NSTimeZone defaultTimeZone];
    local.alertBody = @"";
    local.alertAction = @"";
    NSDictionary *customInfo =
    [NSDictionary dictionaryWithObject:@"ABCD1234" forKey:@"yourKey"];
    local.userInfo = customInfo;
    [[UIApplication sharedApplication] scheduleLocalNotification:local];
    [local release];


    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""message:@""delegate: self cancelButtonTitle:@"Close"otherButtonTitles: nil];
    [alert show];
    [alert release];



    [self performSelector:@selector(myFunc) withObject:nil afterDelay:10.0];

    startDate = [[NSDate date]retain];

    // Create the stop watch timer that fires every 10 ms
    myTime = [NSTimer scheduledTimerWithTimeInterval:1.0/10.0
                                                      target:self
                                                    selector:@selector(updateTimer)
                                                    userInfo:nil
                                                     repeats:YES];

【问题讨论】:

    标签: iphone objective-c push-notification xcode3.2


    【解决方案1】:

    如果卡住是指崩溃,那么您需要遵循内存管理规则来保留计时器。 当计时器不再需要时,将其无效并释放。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      相关资源
      最近更新 更多