Esh*_*nya 2 iphone foreground uilocalnotification
关于为什么本地通知在这里和那里没有正确启动的问题有很多问题,当应用程序处于后台状态时,还有几个问题解释为什么本地通知没有触发,我也经历了这些问题.
但令我惊讶的是,我没有找到任何与前景状态或活动状态相关的通知帖子,即在我的应用程序中我面临这个奇怪的问题,即当应用程序进入后台模式时本地通知会触发,并且当应用程序进入后台模式时它不会触发应用程序处于活动状态或前台模式,令我惊讶的是,即使在通知设置的开启日期到期后,进入后台后,通知也会立即触发.
编辑
我面临的另一个问题是警报没有触发,即我们在didReceive本地通知方法中编写的警报操作,这里是实现代码:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
application.applicationIconBadgeNumber = 0;
NSString *reminderText = [notification.userInfo objectForKey:addViewController.textField.text];
[self.addViewController showReminder:reminderText];
}
Run Code Online (Sandbox Code Playgroud)
这是showReminder方法,它存在于另一个控制器中,即:
//Notification alert
- (void)showReminder:(NSString *)text
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Reminder" message:text delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 10, 40, 40)];
UIImage *image= [UIImage imageNamed:@"icon@2x.png"];
[imageView setImage:image];
[alertView addSubview:imageView];
[imageView release];
[alertView show];
[alertView release];
}
Run Code Online (Sandbox Code Playgroud)
很抱歉,如果此问题不需要在stackoverflow中提问或发帖.
任何人请发表您的建议,任何帮助很高兴!
在此先感谢所有:)
归档时间: |
|
查看次数: |
3642 次 |
最近记录: |