After trying to work on someone else's code, and so many different iterations, I could not understand it I am what I am doing on the calendar month view date. I am trying to present a calendar in month view functions such as calendar.app, but unfortunately in some countries like Australia, UK, some users are reporting wrong alignment of Days to Dates. For example in Australia it displays on 17 March on Friday.
- (zero) setCalendar {NSCalendar * gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGorian Calendar: Any help is highly appreciated! ]; NSDateComponents * comps = [Gregory Component: Date from Units: [Date of NSDT]]; Self.currentDate = [Gregorian dateformscompatible: comps]; NSInteger weekdayInteger = [Comps on weekdays]; CurrentMonth = [comps month]; Current year = [compose year]; NSString * dateString = [[NSString stringWithFormat: @ "% @", currentDATE] substringToIndex: 10]; NSArray * array = [separation string from dateString components: @ "-"]; NSInteger currentDay = [[Array ObjectAntIndex: 2] Integues]; CurrentMonthConstant = currentMonth; CurrentYearConstant = currentYear; CurrentDayConstant = currentDay; CurrentConstantDate = [NSString stringWithFormat: @ "% d /% d /% d", CurrentDecant, Presentmonth Constant, Current Active Constant]; CurrentFirstDay = ((8 + weekdayInteger- (currentDay% 7)) 7%); If (current formaldehyde == 0) currentFastDay = 7; [Gregorian release]; }
And this is how the calendar is being populated:
- (zero) filler: (NSITFor) Weekstst of the month: (NSiEteger ) Days of the year: (NSInteger) year {currentMonth = months; CurrentYear = year; CurrentFirstDay = working days =; UIButton * temp; NSITGAR Number of Diseases = [Heterograft Day: Month Year: Year: Year]; CurrentLastDay = (currentFirstDay + NUMBEROFDAYS -1)% 7; If (current day == 0) present = 7; NSString * month name = [self meeting: month]; NSInteger Grid = (Workday-1); MonthLabel.text = [NSString stringWithFormat: @ "% @% d", monthname, year]; For (int i = 1; i & lt; = numberOfDays; i ++) {if ([FrontView excelstostring: @ "view1"]) temp = [arr_View2Buttons ObjectAddindx: Grid]; Else temp = [arr_View1Buttons objectAtIndex: grid]; [Temp setBackgroundImage: State for Zero: UIControlStateNormal]; [Temp setUserInteractionEnabled: TRUE]; UILBL * ALLL = (UILBL *) [Temp viewWithTag: 123]; [ALLL settext: [NSSTING string with format: @ "% d", i]]; // Check for today (Current Data Constant == i & amp; amp; & amp; amp; amp; amp; & amp; amp; amp; amp; amp; & amp; amp; amp; amp; amp; & amp; amp; amp; amp;;; Current Brain Concentent == Current Churn & Current YEARConstant == Current Year) {[aLbl setTextColor: [UIColor blueColor]] ; } Other {[ALLL Settextcore: [UIColor colorWithRed: 69 / 255.0 Green: 2 / 255.0 Blue: 71 / 255.0 alpha: 1.0]]; } [Temp setTag: i]; Grid ++; If (grid == 35) grid = 0; }} and finally load the watchdrum:
- (zero) viewDidoadload {[Super Viewedload]; [Self set calendar]; // Set view [self.view1 setFrame: CGRectMake (0, 45,320,232)]; [Self.view2 setFrame: CGRactMake (0,277,320,232)]; [Self.view addSubview: self.view1]; [Self.view addSubview: self.view2]; FrontView = @ "view2"; [Self-publishing calender: troupe festival weekstates: current fiscal year: current year]; FrontView = @ "view1"; }
You have to change the code
Replace NSCalendar * Gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]
with
NSCalendar * currentCalendar = [NSCalendar currentCalendar];
This will identify the current calendar device and will perform accordingly
Hope this will solve your problem ...
Comments
Post a Comment