기도 시간을 생성하는 앱 (하루에 5 번) 5 가지기도에 대한 알림을 만들고 싶지만 일부 계산을 기준으로 매일 바뀌는 문제입니다.서로 다른 시간에 지역 알림 반복
편집 :
계산이 다른 도시에 대한 사용자 변경 사항이 시간이 따라 업데이트 할 수 있도록 GPS 위치를 기반으로 수행됩니다. 나는 날짜, 시간대를 입력하고, GPS 좌표로 좌표를 매기고 그 주어진 날/위치에 대한기도 시간 값을 (HH : mm) 형식으로 얻는다. 이제 Notfications를 설정해야합니다. 나는 그들을 어디에 둘 것인지 확실하지 않다.
여기에 코드
#import "PrayerTimeViewController.h"
#import "PrayTime.h"
@implementation PrayerTimeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
UITabBarItem *tbi = [self tabBarItem];
[tbi setTitle:NSLocalizedString(@"PrayerTimes", nil)];
UIImage *i = [UIImage imageNamed:@"11-clock"];
[tbi setImage:i];
[i release];
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Madinah"]];
self.view.backgroundColor = background;
[background release];
locationManager = [[CLLocationManager alloc]init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager startUpdatingLocation];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSTimeInterval t = [[newLocation timestamp] timeIntervalSinceNow];
if (t < -180) {
return;
}
PrayTime *prayerTime = [[PrayTime alloc]init];
[prayerTime setCalcMethod:0];
[prayerTime setFajrAngle:16];
[prayerTime setIshaAngle:14];
[prayerTime setAsrMethod:0];
NSDate *curentDate = [NSDate date];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* compoNents = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:curentDate];
CLLocationCoordinate2D currLoc = [newLocation coordinate];
NSMutableArray *prayerCal = [prayerTime getDatePrayerTimes:[compoNents year] andMonth:[compoNents month] andDay:[compoNents day] andLatitude:currLoc.latitude andLongitude:currLoc.longitude andtimeZone:[[NSTimeZone localTimeZone] secondsFromGMT]/3600];
[prayerTime release];
[fajer setText:[prayerCal objectAtIndex:0]];
// UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSString *time = [prayerCal objectAtIndex:0];
NSString *dates = [NSString stringWithFormat:@"%d-%d-%d %@",[compoNents year],[compoNents month],[compoNents day],time];
NSDateFormatter *dateText = [[NSDateFormatter alloc]init];
[dateText setDateFormat:@"yyyy-MM-dd HH:mm"];
[dateText setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:[[NSTimeZone localTimeZone] secondsFromGMT]]];
NSLog(@"%@",[dateText dateFromString:dates]);
[shrooq setText:[prayerCal objectAtIndex:1]];
[duhur setText:[prayerCal objectAtIndex:2]];
[aser setText:[prayerCal objectAtIndex:3]];
[maghreb setText:[prayerCal objectAtIndex:5]];
[isha setText:[prayerCal objectAtIndex:6]];
[prayerCal release];
}
@end
일부 코드보기 (예 : 계산) – keyser
그냥 5 개의 알림 추가 – NeverBe
시간을 계산하는 방법이나 'UILocalNotification'을 예약하는 방법에 대한 질문이 있습니까? –