【发布时间】:2013-04-04 18:02:51
【问题描述】:
所以,在这个项目的最后阶段,我决定需要通知。
问题是,我在 MainViewController 中设置了一个 UILabel,它从那里的输入中获取它的值,并且我需要将这些值用于我的通知设置中的时间间隔,当应用程序进入后台时会调用该时间间隔。 (代码位于Appdelegate.m)
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSDate *alertTime = [[NSDate date]
dateByAddingTimeInterval:[self.labelone.text intValue] * 60];
UIApplication* app = [UIApplication sharedApplication];
UILocalNotification* notifyAlarm = [[UILocalNotification alloc]
init];
if (notifyAlarm)
{
notifyAlarm.fireDate = alertTime;
notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
notifyAlarm.repeatInterval = 0;
notifyAlarm.soundName = UILocalNotificationDefaultSoundName;
notifyAlarm.alertBody = @"Staff meeting in 30 minutes";
[app scheduleLocalNotification:notifyAlarm];
}
}
我已尝试普遍添加UILabel (self.labelone),但无论我尝试什么,它都会引发错误。任何帮助或提示将不胜感激!
【问题讨论】:
-
您的
labelone位于MainViewController中,因此您无法通过self.....中的Appdelegate访问它。 -
我是这么想的,但我该怎么办? labelone 根本无法识别。
标签: ios objective-c xcode