2011-06-07 19 views

回答

1

所以我認爲你在這裏正確的軌道:不知道我可以添加更多。

您可以使用本地通知在任何給定時間顯示警報。正如您從教程中看到的,當您的應用處於前臺時,通知不會被觸發。

但是沒有什麼可以阻止您在應用程序處於前臺時在應用程序中編寫代碼時提醒用戶需要通知:這可能更理想。您可能希望利用在前臺提供給您的UI選項來做不同的事情,或者只顯示自己的UIAlertView。

+0

感謝您的回覆..但我無法找到它在教程中指定的位置,只有當appln位於後臺而不是前臺時纔會啓動通知..您能幫忙嗎? – learner2010 2011-06-08 13:30:37

+0

我得到它的工作...感謝您的幫助.. – learner2010 2011-06-09 13:46:30

0

我可以給你我的短代碼,把具體時間放在日期上... 我試圖計算一個特定的月份時間。 示例(從2011年1月1日至2011年1月1日上午0點0分)。 我住在哪裏,我對格林尼治標準時差有2h的不同尊重。

dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateStyle:NSDateFormatterLongStyle]; 


components = [[NSDateComponents alloc] init]; 
NSCalendar *gregorian = [NSCalendar currentCalendar]; 
[components setMonth:1]; 
[components setHour:0]; 
[components setMinute:0]; 
[components setSecond:0]; 
dategre = [gregorian dateByAddingComponents:components toDate:[datePicker date] options:0]; 

//These steps below are important to put your specific date, in this case specific hour 
selected2 = [dateFormatter stringFromDate:dategre]; 
dategre = [dateFormatter dateFromString:selected2]; 

//你會看到在調試器控制檯是這樣的: //datePicker.date = 2011-01-01 8時42分十六秒GMT // dategre = 2011-01-31 22:00 :00 GMT(對我們來說,這是在上午12時00分〇〇秒等於2011年2月1日)

我希望我可以幫你,

再見,

威利。

相關問題