Scenario:
UIScrollView has a UIButton. Tapping the UIButton leads to a UIPopoverController presenting itself from a specified rect. The UIPopoverController’s contentViewController is a UIViewController with a UIDatePicker.
Code that is fired when the button is tapped (button is of type custom with touch up inside tap registered):
- (void)showCalendar:(id)sender {
dateViewController = [[UIViewController alloc] init];
datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 240, 200)];
datePicker.datePickerMode = UIDatePickerModeDate;
datePicker.hidden = NO;
datePicker.date = [NSDate date];
[datePicker addTarget:self
action:@selector(DateChanged:)
forControlEvents:UIControlEventValueChanged];
NSLocale *US = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSCalendar *cal = [NSCalendar currentCalendar];
[cal setLocale:US];
[datePicker setCalendar:cal];
[datePicker setMaximumDate:[NSDate date]];
dateViewController.view = datePicker;
dateViewController.contentSizeForViewInPopover = CGSizeMake(240, 200);
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:dateViewController];
self.popoverController.delegate = self;
NSLog(@"YESYESYES");
[self.popoverController presentPopoverFromRect:CGRectMake(753, 513, 1, 1) inView:parentView permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
NSLog(@"NONONO");
}
There is a noticeable 1 second or more lag between the two NSLog statements when I connect the device to Xcode and run the app. What could be the reason for such a lag?
Solved the issued by replacing
with