我正在處理loacl通知通知,並且成功完成。但我不想設置從選擇器通知我想設置通知firetime哪個用戶想要通知。我給了文本字段輸入時間,並希望按用戶時間設置。設置用戶輸入本地通知的時間
假設用戶進入下午1點00分那麼今天通知正值下午1點
下面是我的代碼 -
NSCalendar *calendar = [NSCalendar currentCalendar]; // gets default calendar
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]]; // gets the year, month, day,hour and minutesfor today's date
[components setHour:txtStartTime.text];
// [components setMinute:12];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [calendar dateFromComponents:components];
localNotification.timeZone = [NSTimeZone localTimeZone];
localNotification.alertBody = txtSubjectName.text;
localNotification.alertAction = @"Lecture Notification";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[self dismissViewControllerAnimated:YES completion:nil];