Posts

Post not yet marked as solved
4 Replies
546 Views
Hi,I was created the NSDate using NSCalendar with local time zone(Sydney/Australia), but it returns wrong dateNSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setDay:3]; [comps setMonth:10]; [comps setYear:2019]; [comps setHour:23]; [comps setMinute:00]; NSDate *date = [[NSCalendar currentCalendar] dateFromComponents:comps]; NSCalendar *calendar =[NSCalendar currentCalendar]; calendar.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:([[NSTimeZone localTimeZone] secondsFromGMT])]; NSDate *date1 = [calendar dateFromComponents: comps]; NSCalendar *geoCalender = [[NSCalendar alloc]initWithCalendarIdentifier:@"gregorian"]; geoCalender.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:([[NSTimeZone localTimeZone] secondsFromGMT])]; NSDate *geoDate = [geoCalender dateFromComponents: comps]; NSLog(@"date: %@", date); NSLog(@"date: %@", date1); NSLog(@"date: %@", geoDate); NSDateComponents *comps1 = [[NSDateComponents alloc] init]; [comps1 setDay:7]; [comps1 setMonth:10]; [comps1 setYear:2019]; [comps1 setHour:23]; [comps1 setMinute:00]; NSDate *date2 = [[NSCalendar currentCalendar] dateFromComponents:comps1]; NSDate *date3 = [calendar dateFromComponents: comps1]; NSDate *geoDate1 = [geoCalender dateFromComponents: comps1]; NSLog(@"date: %@", date2); NSLog(@"date: %@", date3); NSLog(@"date: %@", geoDate1);In the above code snippet return the output dates as follow2019-12-06 20:27:18.705789+1100 SampleiOS[78970:498109] date: Thu Oct 3 23:00:00 20192019-12-06 20:27:18.706128+1100 SampleiOS[78970:498109] date: Thu Oct 3 22:00:00 20192019-12-06 20:27:18.706467+1100 SampleiOS[78970:498109] date: Thu Oct 3 22:00:00 20192019-12-06 20:27:18.706831+1100 SampleiOS[78970:498109] date: Mon Oct 7 23:00:00 20192019-12-06 20:27:18.707043+1100 SampleiOS[78970:498109] date: Mon Oct 7 23:00:00 20192019-12-06 20:27:18.707201+1100 SampleiOS[78970:498109] date: Mon Oct 7 23:00:00 2019Can you please explain which creation of NSDate as correct?
Posted
by Sasi@3595.
Last updated
.
Post not yet marked as solved
1 Replies
627 Views
Description: we are adding custom UIView(have drawRect) inside the UIScrollView and its content size as more than 5500(width or height) then the UIScrollView behave strangely.Note: if we remove the drawRect method then it will working fine.Steps to Reproduce:Run the attached projectSee the reported issueExpected Behavior: - Subview of scroll view, draw method workingActual Behavior: - Subview of scroll view, draw method not workingCode Snippet :- (void)viewDidLoad { [super viewDidLoad]; //// create scroll view UIScrollView* scrollView = [[UIScrollView alloc] init]; scrollView.backgroundColor = UIColor.redColor; scrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); scrollView.contentSize = CGSizeMake(6000, self.view.frame.size.height); //// create custom view with drawRect method CustomView* customView = [[CustomView alloc] initWithFrame:CGRectMake(0, 0, 6000, self.view.frame.size.height)]; //// add views to super view [self.view addSubview:scrollView]; [scrollView addSubview:customView];}CustomView:- (CustomView*)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if(self) { self.backgroundColor = UIColor.blueColor; } return self;}- (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 10); CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor); CGContextMoveToPoint(context, 0, self.frame.size.height / 2); CGContextAddLineToPoint(context, self.frame.size.width, self.frame.size.height / 2); CGContextStrokePath(context);}@endSample: https://drive.google.com/open?id=1446iyIvd4lax5p4s2TPAf5TEGdNYy3xgScreen record: https://drive.google.com/open?id=1rxyUhdq66GjTHx_P2p-CYUL7LtqMTRGN
Posted
by Sasi@3595.
Last updated
.
Post not yet marked as solved
1 Replies
369 Views
Description: We are adding UILabels as subviews of UIView on vertical manner and height of the subviews as calculated by current display width. If height of the subview as decimal value then unwanted spaces will be displayed between subviews.Steps to Reproduce:Run the attached projectSee the reported issueExpected Behavior: Remove the unwanted space between the subviewsActual Behavior: There is some unwanted space between the subviewsCode Snippet :- (void)viewDidLoad { [super viewDidLoad]; [self view].backgroundColor = UIColor.redColor; //// If the height value has decimal value then the issue will raise. double heightValue = 36.60f; double offsetValue = 100; for (int i = 0; i < 10; i++) { UILabel* label = [[UILabel alloc] init]; label.backgroundColor = UIColor.whiteColor; label.text = @"Demo"; label.frame = CGRectMake (offsetValue, offsetValue + i * heightValue, offsetValue, heightValue); [self.view addSubview:label]; }}Sample: https://drive.google.com/open?id=1Lf1JXbEWupwMoh2A5ohcolSLgJDrGjCpScreenShots: https://drive.google.com/open?id=1VUY6-Sv34_vScqs1Qoh_lCRSMt137ER4
Posted
by Sasi@3595.
Last updated
.
Post not yet marked as solved
4 Replies
761 Views
Description: We are adding UILabels as subviews of UIView on vertical manner and height of the subviews as calculated by current display width. If height of the subview as decimal value then unwanted spaces will be displayed between subviews.Steps to Reproduce:Run the attached projectSee the reported issueExpected Behavior: Remove the unwanted space between the subviewsActual Behavior: There is some unwanted space between the subviewsCode Snippet :- (void)viewDidLoad { [super viewDidLoad]; [self view].backgroundColor = UIColor.redColor; //// If the height value has decimal value then the issue will raise. double heightValue = 36.60f; double offsetValue = 100; for (int i = 0; i < 10; i++) { UILabel* label = [[UILabel alloc] init]; label.backgroundColor = UIColor.whiteColor; label.text = @"Demo"; label.frame = CGRectMake (offsetValue, offsetValue + i * heightValue, offsetValue, heightValue); [self.view addSubview:label]; }}Sample: https://drive.google.com/open?id=1Lf1JXbEWupwMoh2A5ohcolSLgJDrGjCpScreenShots: https://drive.google.com/open?id=1VUY6-Sv34_vScqs1Qoh_lCRSMt137ER4
Posted
by Sasi@3595.
Last updated
.